Dropdown list validation

here’s my dropdown list

<?php $dataCategory=ArrayHelper::map(Movies::find()->asArray()->all(), 'id', 'movie_name');


                       echo $form->field($model, 'movie_id')->dropDownList($dataCategory, 


									 ['prompt'=>'-Choose a Movie-',


									  'onchange'=>'


									   $.get( "'.Url::toRoute('screenticketbooking/dependdrop').'", { id: $(this).val() } )


                        .done(function( data )


               {


                          $( "select#title" ).html( data );


                        });


            '])->label(''); ?> 


							


<?php $dataPost=ArrayHelper::map(MovieShows::find()->where('movie_id=:mov_id',['mov_id'=>$model->movie_id])->asArray()->all(), 'id', 'start_date'); 


	   echo $form->field($model, 'show_date')


				->dropDownList(


				$dataPost,           


				['id'=>'title','prompt'=>'-Select a Date-']


				)->label('');					


?>	

i have set show_date and movie_id as required in the model but the validation don’t work with ‘show_date’ (even if it is not set it goes to another page on clicking ok)

what should i do to validate the field in the second drop down???

thanks.

Due to user defined id value #title, it not call the model validation, so use the id that autogenerated .

some thing like this #[color="#FF8C00"]modelname[/color]-show_date , just remove the id, and use like thiis.

if i remove id then dates are not displayed…


<?php $dataCategory=ArrayHelper::map(Movies::find()->asArray()->all(), 'id', 'movie_name'); echo $form->field($model, 'movie_id')->dropDownList($dataCategory, ['prompt'=>'-Choose a Movie-', 'onchange'=>' $.get( "'.Url::toRoute('screenticketbooking/dependdrop').'", { id: $(this).val() } ) .done(function( data ) { $( "[b]#Exam-show_date[/b]" ).html( data ); }); '])->label(''); ?>  <?php $dataPost=ArrayHelper::map(MovieShows::find()->where('movie_id=:mov_id',['mov_id'=>$model->movie_id])->asArray()->all(), 'id', 'start_date'); echo $form->field($model, '[b]show_date[/b]') ->dropDownList( $dataPost, ['id'=>'title','prompt'=>'-Select a Date-'] )->label(''); ?> 

if the table name is exam mean , the Model Name generated is EXAM, so the id is #Exam-show_date, view source n your browser and find the dropdown id, otherwise please put your Model controller view code here.