TbHtml::activeListBox PHP Method

activeListBox() public static method

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
    public static function activeListBox($model, $attribute, $data, $htmlOptions = array())
    {
        TbArray::defaultValue('displaySize', 4, $htmlOptions);
        self::addCssClass('form-control', $htmlOptions);
        return self::activeDropDownList($model, $attribute, $data, $htmlOptions);
    }

Usage Example

Example #1
0
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);
All Usage Examples Of TbHtml::activeListBox
TbHtml