I have this model:
public function attributeLabels()
{
return [
'exam_id' => Yii::t('aca', 'Exam ID'),
'exam_exam_group_id' => Yii::t('aca', 'Exam Group'),
'exam_group_year_id' => Yii::t('aca', 'Academic Year'),
'exam_group_term_id' => Yii::t('aca', 'Academic Term'),
'exam_group_class_group_id' => Yii::t('aca', 'Class Group'),
'exam_group_class_id' => Yii::t('aca', 'Class'),
'exam_group_class_arm_id' => Yii::t('aca', 'Class Arm'),
'exam_group_subject_id' => Yii::t('aca', 'Subject'),
];
}
and DependentController
public function actionGetclassarm($id)
{
$rows = \app\modules\academic\models\AcaClassArms::find()->where(['class_arm_class_id' => $id,'is_status'=>0])->all();
echo "<option value=''>".Yii::t('app', '--- Select Class Arm ---')."</option>";
if(count($rows)>0){
foreach($rows as $row){
echo "<option value='$row->class_arm_id'>$row->class_arm_name</option>";
}
}
else{
echo "";
}
}
View
<?= $form->field($model, 'exam_group_class_id')->widget(Select2::classname(), [
'data' => ArrayHelper::map(\app\modules\academic\models\AcaClassMaster::find()->where(['is_status' => 0])->all(),'class_id','class_name','classGroups.class_group_name'),
'language' => 'en',
'options' => ['placeholder' => '--- Select Class ---',
'onchange'=>'
$.get( "'.Url::toRoute('dependent/getclassarm').'", { id: $(this).val() } )
.done(function( data ) {
$( "#'.Html::getInputId($model, 'exam_group_class_arm_id').'" ).html( data );
}
);'
],
'pluginOptions' => [
'allowClear' => true
],
]); ?>
I want the dropdownlist above to load two other dropdownlists. Am only able to load one as shown below:
<?= $form->field($model, 'exam_group_class_arm_id')->widget(Select2::classname(), [
'data' => ArrayHelper::map(\app\modules\academic\models\AcaClassArms::findAll(['class_arm_id' => $model->exam_group_class_arm_id]),'class_arm_id','class_arm_name'),
'language' => 'en',
'options' => ['placeholder' => '--- Select Class Arm ---'],
'pluginOptions' => [
'allowClear' => true
],
]); ?>
Am unable to load the second dropdownlist that is shown below
exam_group_subject_id
for
app\modules\academic\models\AcaSubjects
How do I achieve this.
Thanks