yii2

Yii Inputs showcase: CHtml static and dynamic data loading

Dropdownlist:
Format:
public static string activeDropDownList(CModel $model,
string $attribute,
array $data,
array $htmlOptions=array ( ))

Drop down with dynamic data:
dropDownListRow(
$Regions,
'region',
CHtml::listData(Regions::model()->findAll(),'id','region'),
array('empty'=>'Select'));

Drop down with static data
echo CHtml::activeDropDownList($model,
'name',
array('1'=>'One','2'=>'Two'),
array('empty'=>'Select Option'));

activeCheckBoxList:
Dynamic data in check box:
$type=CHtml::listData(Types::model()->findAll(),'id','type');
echo CHtml::activeCheckBoxList($model,'name',$type);

Static data in check box:
echo $form->checkBoxList($model,'name',array('1'=>'One','2'=>'Two'));


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *