Skip to content
Advertisement

Select field Old value cannot be displayed in laravel

I’m having a user registration form with a select field, When ever I get an error on the form user redirected to the form and display the previously entered values

I able to display old values for the text fields but I am finding it difficult to display old values for the select field,

My select field as follows,

JavaScript

I’m using laravel 7

Advertisement

Answer

First of all you need value for each option and i don’t see any value for your first option. Then you need a logic to check if the option was selected and assign “selected Attribute” to HTML :

JavaScript

Above example can just demonstrate how to select the option, but for cleaner code you better come with array of option as mentioned in this topic .

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement