echo Html::activeDropDownList( $model, 'category_id', ArrayHelper::map(Category::find()->all(), 'id', 'name'), ['prompt'=>'Select Category','id'=>Html::getInputId($model, 'category_id')] );
echo Html::input('text', 'username', '', ['id' => Html::getInputId($model, 'username')]);In this example, the Html::input() method is used to generate a text input element for the username field. The 'id' attribute for the input element is generated using the Html::getInputId() method. Again, this ensures that the ID attribute is unique and consistent with the model's attribute name. Package library: yii\helpers\Html.