Answer the question
In order to leave comments, you need to log in
How to get rid of enumeration of strings in an array?
How to get rid of enumeration of strings in an array?
The screenshot shows 0 and 1 in the list. How can you get rid of this?
Controller:
$ships = Ship_company::find()->select('name')->all();
<?php foreach($ships as $ship): ?>
<?php $items[]= [$ship->name => $ship->name];?>
<?php endforeach; ?>
<?= $form->field($post, 'Who_ship')->dropDownList($items, ['promt' => 'Select']); ?>
Answer the question
In order to leave comments, you need to log in
Good afternoon.
And it would be more correct, I think, like this:
in the Ship_company model
public static function getNamges()
{
return ArrayHelper::map( self::find()->select(['name', 'id'])->all(), 'id', 'name');
}
$form->field($post, 'Who_ship')->dropDownList(Ship_company::getNames(), ['promt' => 'Select']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question