Where Clause in Dropdownlist

I have two models:

[b]

QuestionCategories

[/b]




    public function attributeLabels()

    {

        return [

            'question_category_id' => 'ID',

            'course_id' => Yii::t('course', 'Course'),

            'name' => Yii::t('course', 'Question Category Name'),

            'is_status' => Yii::t('course', 'Is Status'),

        ];

    }



[b]

Questions

[/b]




    public function attributeLabels()

    {

        return [

            'question_id' => Yii::t('course', 'Question ID'),

            'question_category_id' => Yii::t('course', 'Question Category'),

            'question_course_id' => Yii::t('course', 'Course'),

            'instructor_id' => Yii::t('course', 'Instructor'),

            'question_name' => Yii::t('course', 'Question Name'),

        ];

    }



In the View of Questions, I want to create a Dropdownlist where the course_id in QuestionCategories is equal to the question_course_id in the Questions

How do I achieve this?

See what I have done so far




                <?= $form->field($model, 'question_category_id')->widget(Select2::classname(), [

                    'data' => ArrayHelper::map(QuestionCategories::find()->all(),'question_category_id','name'),

                    'language' => 'en',

                    'options' => ['placeholder' => 'Select Question Category ...'],

                    'pluginOptions' => [

                    'allowClear' => true

                    ],

                ]);

                ?>  



You must join two tables and use result to use for dropdown list