Answer the question
In order to leave comments, you need to log in
Adding an option dropDownList attribute?
Good afternoon I display a drop-down list through dropDownList
, it displays
<select id="navigations-parent_id" class="form-control" name="Navigations[parent_id]" aria-invalid="false">
<option value="1" selected="">Корень</option>
<option value="2">test</option>
<option value="3">test2</option>
</select>
<?= $form->field($model->main, 'parent_id', ['labelOptions' => ['class' => 'control-label col-md-3']])->dropDownList(Navigations::getTreeList(), ['class' => 'form-control', ]); ?>
Answer the question
In order to leave comments, you need to log in
option you have is formed from an array that gives Navigations::getTreeList(). That's where you add it.
or like this:
<?php
$list = Navigations::getTreeList();
$list[] = 'новый option';
?>
<?= $form->field($model->main, 'parent_id', ['labelOptions' => ['class' => 'control-label col-md-3']])->dropDownList($list, ['class' => 'form-control', ]); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question