Generates a list box for a model attribute.
public static activeListBox ( CModel $model, string $attribute, array $data, array $htmlOptions = [] ) : string | ||
$model | CModel | the data model. |
$attribute | string | the attribute. |
$data | array | data for generating the list options (value=>display). |
$htmlOptions | array | additional HTML attributes. |
return | string | the generated list box |
echo $form->error($model, 'status'); ?> </div> <br/> <div class="row"> <?php //$gprofile = Profile::model()->with('groups')->findbyPk($model->id); ?> <?php echo $form->labelEx($profile, 'group_id'); ?> <?php echo TbHtml::activeListBox($profile, 'group_id', TbHtml::listData(Group::model()->findAll(), 'id', 'name'), array('multiple' => 'multiple')); ?> <?php echo $form->error($profile, 'group_id'); ?> </div> <br/> <?php $profileFields = ProfileField::model()->forOwner()->sort()->findAll(); if ($profileFields) { foreach ($profileFields as $field) { if ($field->varname == 'branch_id') { ?> <div class="row"> <?php echo $form->labelEx($profile, $field->varname);
/** * Renders a list box for a model attribute. * @param CModel $model the data model. * @param string $attribute the attribute. * @param array $data data for generating the list options (value=>display). * @param array $htmlOptions additional HTML attributes. * @return string the generated list box. * @see TbHtml::activeListBox */ public function listBox($model, $attribute, $data, $htmlOptions = array()) { return TbHtml::activeListBox($model, $attribute, $data, $htmlOptions); }
public function testActiveListBox() { $I = $this->codeGuy; $html = TbHtml::activeListBox(new Dummy(), 'listbox', array('1', '2', '3', '4', '5'), array('class' => 'list', 'empty' => 'Empty text', 'size' => TbHtml::INPUT_SIZE_LARGE, 'textAlign' => TbHtml::TEXT_ALIGN_CENTER)); $select = $I->createNode($html, 'select'); $I->seeNodeCssClass($select, 'input-large text-center list'); $I->seeNodeAttributes($select, array('name' => 'Dummy[listbox]', 'id' => 'Dummy_listbox', 'size' => 4)); $html = TbHtml::activeListBox(new Dummy(), 'listbox', array('1', '2', '3', '4', '5'), array('multiple' => true)); $select = $I->createNode($html, 'select'); $I->seeNodeAttribute($select, 'name', 'Dummy[listbox][]'); }
/** * Renders a list box for a model attribute. * This method is a wrapper of {@link CHtml::activeListBox}. * Please check {@link CHtml::activeListBox} for detailed information * about the parameters for this method. * @param CModel $model the data model * @param string $attribute the attribute * @param array $data data for generating the list options (value=>display) * @param array $htmlOptions additional HTML attributes. * @return string the generated list box */ public function listBox($model, $attribute, $data, $htmlOptions = array()) { return $this->wrapControl(TbHtml::activeListBox($model, $attribute, $data, $htmlOptions)); }