A
A
abrakadana2016-06-01 14:03:57
Yii
abrakadana, 2016-06-01 14:03:57

Is it possible to pass a value for the dropDownList field?

I deduce dropDownList, in it the list and the first empty field. Can value be set to a value? It goes empty.
<option value="">Выберите поле</option>

<?= $form->field($model, 'param')->dropDownList(ArrayHelper::map($array,'id','name'), ['prompt' => 'Выберите поле ']);
  ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-06-01
@abrakadana

the only way:

$values = ArrayHelper::map($array,'id','name');
$values[<нужное значение>] = 'Выберите поле ';
$form->field($model, 'param')->dropDownList($values);

but it is not absolutely clear - what for to you to set value. What prevents on the server side from simply checking this attribute for empty?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question