I have a checkbox list in my yii2 forum.
It is like this.
<?php
$list = ArrayHelper::map(Publisher::find()->all(),'user_id','name');
echo $form->field($model, 'publisher_name')->widget(Select2::classname(),[
'data' => $list,
'options' => [
'multiple' => true,
'placeholder' => 'Choose publishers'
]
]);
?>
It is taking values from the database. Also, I have used for each to populate the model in the controller. Now I want to populate this checkbox list with the drop downs.
My drop downs are as follows.
<?= $form->field($model, 'country')->dropDownList(Countries::getCountries(),
['id' => 'country_id', 'prompt' => 'Select countries'])
?>
And
<?= $form->field($model, 'state')->widget(DepDrop::classname(), [
//'data' => Regions::getRegions($model->country),
'options' => ['id' => 'region_id', 'prompt' => 'Choose a country first'],
'pluginOptions' => [
'depends' => ['country_id'],
'placeholder' => 'Select a state',
'url' => Url::to(['/regions/regions'])
]
]) ?>
And
<?= $form->field($model, 'city')->widget(DepDrop::classname(), [
//'data' => Cities::getCities($model->country),
'options' => ['id' => 'city_id', 'prompt' => 'Select a state'],
'pluginOptions' => [
'depends' => ['country_id','region_id'],
'placeholder' => 'Select',
'url' => Url::to(['/cities/cities'])
]
]) ?>
And there are more drop downs whIch I will use I want to know what all are the ways i can populate the checkbox list? Are there any ways to do that?