Mutate Data before Create (calculated column)
Hello.
I need to calculate a column with series & id.
The fields are Id, Series, NumExp and I need numExp to be equal to SERIES-ID
If series is ABC and id is 20, I need numExp to be ABC20
I have tried this mutateFormDataBeforeCreate but it is not working.
Is there a boot method in the Model or something, please?
Tks.
5 Replies
You can use
virtualAs
in your migration
https://filamentphp.com/docs/3.x/forms/fields/checkbox-list#customizing-the-relationship-option-labelsI already tried but I get an error because Id field is not available for virtualAs.
Okay, you need this one
protected function handleRecordCreation(array $data): Model
just call the parent method then update the field you wantTks. And where (in which file) do I have to put that function handleRecordCreation() ??
Solution
Finally I have created an Observer.
Thank you.