I want to build a form that is going to be used to enter data for new records as well as for editing existing records.
How do i define the form input's value attribute knowing that it can be either blank or the existing record's value, if i'm creating a new one or editing, or the input entered by the user, if validation fails?
My current solution is to combine old() with an instance of the model i'm editing. As an example, in a form to edit a user's data, the value for the input element for the user's name would be something like old('name', !empty($user) ? $user->name : '').
Is this the right way to do this sort of thing or is there an easier (more artisan) way?
I'm using Laravel 5.2.
Thanks in advance.