I have following code in my controller:
public function getData($property)
{
$data = array(
'type'=>array(
'PC',
'Laptop'
),
'brand'=>array(
'1'=>array(
'ASUS PC',
'DELL PC',
),
'2'=>array(
'ASUS laptop',
'DELL laptop',
),
);
return $data[$property];
}
In my view:
<?= $form->dropDownList($model, 'type',$model->getData('type'), array('class' => 'form-control')) ?>
This code(in the view) returns types.(e.g shows pc and laptop options in the drop down ).
I need to develop dependant drop that will show 'ASUS PC'and 'DELL PC' in the drop down, if user chooses pc option from the the first drop down(type). How can I do it.
1) add two dropdown fields in view page.
Controller
Note : Make sure to set permission to access this action in accessRules