显示下拉列表过滤数据?

时间:2016-01-21 05:34:49

标签: php yii2 yii2-advanced-app

<?= $form->field($model, 'SRF_STUDENT_ID')->dropdownList(
                    ArrayHelper::map(StudentDetails::find()->all(),'STUDENT_REGISTRATION_ID','STUDENT_REGISTRATION_ID'),
                    ['prompt'=>'Select Student Id']); ?>

如何在下拉列表中设置条件。我希望从StudentDetails中选择STUDENT_REGISTRATION_ID,其中is_select = 0; 数据结果集下拉列表。请帮助我。

1 个答案:

答案 0 :(得分:1)

试试这个:

<?= $form->field($model, 'SRF_STUDENT_ID')->dropdownList(
                 ArrayHelper::map(StudentDetails::find()->where(['is_select' => 0])->all(),'STUDENT_REGISTRATION_ID','STUDENT_REGISTRATION_ID'),
                ['prompt'=>'Select Student Id']); ?>