I have a form with a dropdown list and I am using select2 plugin for searchable dropdown. If there is an error on form submission the form page redirect with a message and the selected drop down value lose it value and user have to reselect it. How can I maintain the drop down value?
Try this
<option <?php if(isset($_POST['name_of_this_dropdown'])){echo 'selected';};?>>some_value_here</option>