How to make a drop-down list in yii2 based on ActiveForm and model? In yii, there was a listData method

CHtml::dropDownList( 'categories', $category, CHtml::listData( Categories::model()->findAll("Status=1"), 'id', 'name' ) ); 

Now in Html there is no such

    2 answers 2

     <?php use yii\helpers\ArrayHelper; use backend\models\Standard; ?> <?= Html::activeDropDownList( $category, 'categories', ArrayHelper::map( Categories::find()->all(), 'id', 'name' ) ) ?> 

    In Yii2, ArrayHelper comes to replace lists with data CHtml .

      Here is described in detail the work with the dropdownlist http://web-sprints.ru/yii2-dropdownlist-vyipadayushhiy-spisok/

      • one
        Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky