N
N
nnkrasovok2019-05-12 20:24:38
Yii
nnkrasovok, 2019-05-12 20:24:38

How to display a hidden field depending on the selected value in the list?

there is a field of type dropDownList. the data in it is deduced from a DB.

<?= $form->field($model, 'id_education_stage')->dropDownList(
                    \yii\helpers\ArrayHelper::map(\app\models\EducationStage::find()->all(), 'id', 'name'),
                ) ?>

please tell me how to display one more field dropDownList (hidden) if the value id=1 is selected in the list. it is desirable to write the code. I understand what is needed through js. but I still have a hard time integrating JS with YII2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-05-12
@slo_nik

Hope it helps you .
jQuery/js can be included in yii2 via registerJs() , registerJsFile()

$this->registerJs("
  $(function(){
      alert('test')
   })
", View::POS_END);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question