I have an app which has dynamic form fields (ones which may or may not be present depending on the value of another field).
I already use request objects to do basic validation on every field.
However it is possible to have a situation where a user changes a previously submitted form value, which causes some fields which are filled in to dissapear. But this on its own will not remove their values from the database.
Right now i have to read the value of the control fields and if their value means that the dynamic fields should not appear i change the values to null, this overwrites any existing values in the database.
Is there a way using request validation or any other laravel feature to do this?
Yes you can! There is a validation rule called sometimes. It will only run the validation for that field if it's actually in the request. This way you won't be posting it to the backend with a null value.