V
V
VitaliyKaliuzhyn2017-04-04 14:41:34
Yii
VitaliyKaliuzhyn, 2017-04-04 14:41:34

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>

And I take it out like this
<?= $form->field($model->main, 'parent_id', ['labelOptions' => ['class' => 'control-label col-md-3']])->dropDownList(Navigations::getTreeList(), ['class' => 'form-control', ]); ?>

How can I add another option attribute to my option?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-04-04
@webinar

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 question

Ask a Question

731 491 924 answers to any question