Reputation: 3515
I am new to laravel 5. I have created a form to edit users info which is populated with information from the DB. After form validation if I get an error, I lose all the info I just modified, and the db info is restored.
My form field look like below:
<input type="text" name="name" value="{{ $user->name }}" id="name" class="form-control"/>
What I would like to see happen is this. If during edit the user clears off the users name from the field and make other changes on the different fields on my form. After a validation failure, I want his recent changes to stick and not the info from the database.
NB: Because of the nature of my form, I cannot bind a model to it.
Upvotes: 5
Views: 2360
Reputation: 9454
You must follow this approach:
<input type="text" name="name" value="{{ old('name', $user->name) }}" id="name" class="form-control"/>
Upvotes: 9