I have modified a year search form in _search.php into dropdownlist form, like this:
<?= echo $form->field($model, 'year')->label('Year')
->dropdownlist($model->getYearsList(), ['prompt'=>'-- Select All Years --',]) ?>
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
When submitted, the gridview in index.php shows only rows according to selected year.
How do I display the selected year from _search.php into index.php such as
< div><?php echo $selectedyear; ?>< /div>
You can get it from Query params, in index write below code.
$selectedyear=$_REQUEST['YourSearchModelName']['year'];
Edit : find class name from class id
$class_data=Class::find->where(['classid'=>$_REQUEST['YourSearchmodelName']['classid']])->one();
$classname=$class_data->classname