hi i wanna use a 3 way dependent drop down without using karthik’s widget. need some help
thanks
hi i wanna use a 3 way dependent drop down without using karthik’s widget. need some help
thanks
i got the answer
view file
<?php $dataCategory=ArrayHelper::map(Theatres::find()->asArray()->all(), 'id', 'theatre_name');
echo $form->field($model, 'theatre_id')->dropDownList($dataCategory,
['prompt'=>'-Choose a Theatre-',
'onchange'=>'
$.get( "'.Url::toRoute('giftvouchers/dependdrop').'", { id: $(this).val() } )
.done(function( data )
{
$( "select#title" ).html( data );
});
'])->label(''); ?>
<?php $dataPost=ArrayHelper::map(Movies::find()->where('id=:mov_id',['mov_id'=>$model->movie_id])->asArray()->all(), 'id', 'movie_name');
echo $form->field($model, 'movie_id')
->dropDownList(
$dataPost,
['id'=>'title',
'prompt'=>'-Select a movie-',
'onchange'=>'
$.get( "'.Url::toRoute('giftvouchers/depend').'", { id: $(this).val() } )
.done(function( data )
{
$( "select#data" ).html( data );
});
']
)->label('');
?>
<?php $dataGet=ArrayHelper::map(ScreenShowTimes::find()->where('id=:show_id',['show_id'=>$model->show_time_id])->asArray()->all(), 'id', 'start_time');
echo $form->field($model, 'show_time_id')
->dropDownList(
$dataGet,
['id'=>'data','prompt'=>'-Select a Time-']
)->label('');
?>
controller
public function actionDependdrop($id)
{
$check =MovieShows::find()->where(["theatre_id" => $id])->all();
echo "<option>-Select Moive-</option>";
foreach($check as $aj)
{
echo "<option value='".$aj->name->movie_name."'>".$aj->name->movie_name."</option>";
}
}
public function actionDepend($id)
{
$movie =Movies::find()->where(["movie_name" => $id])->one();
$show=MovieShows::find()->where(["movie_id" => $movie->id])->one();
$check =ScreenShowTimes::find()->where(["screen_id" => $show->screen_id])->all();
echo "<option>-Select Time-</option>";
foreach($check as $aj)
{
echo "<option value='".$aj->start_time."'>".$aj->start_time."</option>";
}
}