Monday, April 30, 2018

yii2 dropdownlist without model

Yii2 html dropdownlist

Dropdownlist without model example is showing below. In this section Arrayhelper and Html classes are uses. In dropdownlist the first attribute is $name ,the second attribute is $options and third attribute is $items array.

use yii\helpers\Html;
use yii\helpers\ArrayHelper;

Html::dropDownList('user_id', null,
      ArrayHelper::map(User::find()->all(), 'user_id', 'name'))

No comments:

Post a Comment

Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search