I am using DepDrop Widget and all is working fine except the second dropdownlist is not showing the text.
It has 2 empty rows which is somewhat correct, because the database has 2 records which is should display. When selecting another parent, the sub list changes to 1 empty row which is also correct, but it shows empty/clean rows, no text is being displayed.
When I do that, the dropdown does not work. How would I manage multiple dropdown’s with the same name? I want the user to be able to select more than 1 product and handle it as an array of products on the backend.
Your id must still be unique and you must use attribute name in array format (read yii docs/api reference on this).
for ($i=0; $i<10; $i++) {
// use prod id uniquely in your code
$prodId = "products-id-{$i}";
// note the attribute name
echo $form->field($model, "[$i]product")->widget(DepDrop::classname(), [
'options'=>['id'=>$prodId, 'style'=>'width:600px'],
'pluginOptions'=>[
'depends'=>['company-id'],
'placeholder'=>'Select...',
'url'=>Url::to(['/invoice/productspercompany'])
]
]);
}