Hello. It is necessary to draw the title field in option (select). With that, my $ remittances_title is an array. How can you rake it? Sample code below. Tell me where I am stupid, who knows. thank

<?= $form->field($model, 'remittanceInformationType', [ 'inputOptions' => [ 'name' => 'remittanceInformationType', 'id' => 'selectRemittanceInfo', 'data-placeholder' => 'Выберите назначение платежа', ], 'template' => '<div class="row"><div class="col-lg-8 col-md-8 col-sm-8">{input}</div></div>' ])->dropDownList($remittances_type, [ 'prompt' => '', 'title' => $remittances_title, ]); ?> 
  • It's not entirely clear what you need. What exactly do you have in $remittances_type and what in $remittances_title ? And what should select look like? - oakymax
  • if I understand correctly, then you need to use not title but options - so you can set custom attributes for each option yiiframework.com/doc-2.0/… tag - oakymax

1 answer 1

 $remittances_type = [0 => 'val1', 1 => 'val2', 5 => 'val5']; $remittances_title = [0 => 'Опция 1', 1 => 'Опция 2', 5 => 'Опция 5']; echo $form->field($model, 'remittanceInformationType', [ 'inputOptions' => [ 'name' => 'remittanceInformationType', 'id' => 'selectRemittanceInfo', 'data-placeholder' => 'Выберите назначение платежа', ], 'template' => '<div class="row"><div class="col-lg-8 col-md-8 col-sm-8">{input}</div></div>' ])->dropDownList($remittances_type, [ 'prompt' => '', 'options' => array_map(function ($v) { return ['title' => $v]; }, $remittances_title) ]);