Ares Draguna Ares Draguna - 5 years ago 1740
PHP Question

Yii2 dropdownlist WITHOUT $model

I have searched the web far and wide for a solution to this problem. I already know the Yii2 dropdown way is this:

<?php
use yii\helpers\ArrayHelper;
use backend\models\Standard;
?>

<?= Html::activeDropDownList($model, 's_id',
ArrayHelper::map(Standard::find()->all(), 's_id', 'name')) ?>


But I want to make the dropdown without the
$model
... Is there ANY way to do this?

Thank you in advance!

Answer Source

You can also use

Html::dropDownList()

<?= Html::dropDownList('s_id', null,
      ArrayHelper::map(Standard::find()->all(), 's_id', 'name')) ?>

See Yii Manual

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download