Kaustubh
2 years ago
415
2
Laravel

Old Value in Select Option

Posted 2 years ago by Kaustubh

Hi,

I have a form in which there is a select option for Gender, what i want to achive is if my validator fails then its get redirect back with old inputs. but i dont know how to populate my select option with old value.

<select id="gender" name="gender">
    <option value="male">Male</option>
    <option value="female">Female</option>
</select>

I have another question. I have user table in which user has role. When admin update user record his role dropdown should contain all roles but the selected role should be his role which is in his record

Role Dropdown -  HR Manager   ----> selected ..as stored in database
                 Admin
                 Superadmin

Please sign in or create an account to participate in this conversation.