Hi i’m new to yii
I have a question about fields.
Can i have two dropdown fields but one of them is dependent on the other ?
This is the part of my form :
<?= $form->field($model, 'country_id')->dropdownList(country::find()->select(['name'])->indexBy('country_id')->column()
,['prompt'=>'Pick a country']
)?>
<?= $form->field($model, 'city_id')->dropdownList(city::find()->select(['city_name'])->where(['country_id' => $model->country_id])->indexBy('city_id')->column()
,['prompt'=>'Pick a city']
)?>
the tables are like so :
country (country_id , ‘name’)
city (city_id , city_name , country_id)
But $model->country_id return NULL.Anyone have an idea how i should procede ?
informer07
(Adriankosciuk)
2
I think for this you need some javascript code. You can watch about this here https://www.youtube.com/watch?v=ZepxKw8VA7w
soultaker
(Helder Henrique Cabral)
3
If you’re looking for something ‘ready to go’ check this extension:
http://demos.krajee.com/widget-details/depdrop