I’m trying to use depdrop widget http://demos.krajee.com/widget-details/depdrop for a simple 2-level nested dependency.
I have a card model.
In card view form I have :
echo $form->field($model, 'album')->dropDownList(
ArrayHelper::map(Album::find()->all(),'album_id','album_name'),
['id'=>'album_id']);
echo $form->field($model, 'section')->widget(DepDrop::classname(), [
'data'=>[9 => 'Serie B'],
'options'=>['id'=>'section_id', 'placeholder'=>'Select ...'],
'pluginOptions'=>[
'depends'=>['album_id'],
'url'=>Url::to(['subcat']),
]
]);
I think my problem is the output
public function getSubCatList($id) {
$data=Album_section::find()
->where(['album_id'=>$id])
->select(['section_id','section_name'])->all();
return $data;
}
when I change album, firebug shows this JSON
output
[Object { section_id=8, section_name="Serie A TIM"}, Object { section_id=9, section_name="Serie B"}]
0
Object { section_id=8, section_name="Serie A TIM"}
section_id
8
section_name
"Serie A TIM"
1
Object { section_id=9, section_name="Serie B"}
section_id
9
section_name
"Serie B"
selected
""
And the section field has only:
0
blank row
blank row
1
blank row
blank row
Someone could please help me?
Thank you very much