How can I display old input values in a Laravel edit form while still showing the original values on the initial form load? Is it considered good practice to use a ternary operator in the value attribute to check if there’s old input and fall back to the original value if not?
The old() function in Laravel has a default parameter used if no old data is found in the session. You can use the original value as a second parameter to the old() function to display it on the initial form load.
value="{{ old('value', $db_value) }}"
You can also use the ternary operator, as there is not much difference between the two approaches.