Access form data inside beforeFormValidated()
I have country code field, I want to save
+012
(notice plus sign) in database. but on input, I don't want user to insert "+" so I use mutateFormDataUsing()
to append before save, but however this doesn't work with ->unique()
validation, it always try to save to DB.
My codes:
EDIT
I notice that mutateFormDataUsing()
run after validation, so how can I access form data inside ->beforeFormValidated()
?1 Reply
You probably left out some code, but why would you want to do this before validation? Add the validation rules you need (integer, unique, min length 1, max length 3, etc) and then mutate the data after validation (https://filamentphp.com/docs/3.x/panels/resources/creating-records#customizing-data-before-saving).