How can I order this dropDownList based on the column ‘nume’?
<?= $form->field($model, ‘nume’)->dropDownList(\yii\helpers\ArrayHelper::map(\app\models\Consumabile::find()->all(), ‘nume’, ‘nume’), [‘prompt’ => ‘Select consumabil’]
) ?>
How can I order this dropDownList based on the column ‘nume’?
<?= $form->field($model, ‘nume’)->dropDownList(\yii\helpers\ArrayHelper::map(\app\models\Consumabile::find()->all(), ‘nume’, ‘nume’), [‘prompt’ => ‘Select consumabil’]
) ?>
Consumabile::find()->orderBy(['nume' => SORT_ASC or SORT_DESC])->all();
Default order is Ascending Consumabile::find()->orderBy('nume')->all();