Is there a Laravel way of getting a list of only the form fields where the value of the field has changed? Once a user clicks submit I need to know which fields they edited. It does not matter if I get the list before or after the database is updated. It seems like I would have to run a query of the table and then loop through the passed form variables to determine which fields are different, but I hope there is a better way that does not involve javascript. Thanks in advance for the help.
Without JS, whoa slow down cowboy!
You could store all of the initial form values in Session when you create the view and then check the submitted form values against those in the Session.
On my apps I am also storing it on a session and then compare it when the form is submitted.
Thank you for the quick responses. It sounds like a great way to get the result I am looking for. Should have thought about that myself. Thanks again.
When saving a model, you can also use getDirty():
$changedAttributes = $model->getDirty();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community