Welcome Guest, Not a member yet? Register   Sign In
How to set old() to the dropdown menu ?
#1

(This post was last modified: 09-04-2023, 11:24 PM by sknair143.)

Hello,
I'm building form where user can submit some inputs. I check for validation errors and re display the form with error messages and also i use <?=old('filed_name')?> to display old entered data.

Everything works for input box but, i have dropdown box where user cans select gender, But how we can show the old data on this dropdown.

My code (Textbox) :

Code:
<input type="text" name="first_name" value="<?=old('first_name')?>" id="firstName">

My code (Dropdown) : 

PHP Code:
  <select id="defaultSelect" value="<?= old('gender') ?>" name="gender" class="form-select">
                                    <option value="">Select</option>
                                    <option value="Male">Male</option>
                                    <option value="Female">Female</option>

                                </select

But this dropdown not working with old selected values.
Reply


Messages In This Thread
How to set old() to the dropdown menu ? - by sknair143 - 09-04-2023, 11:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB