Unexpected Behavior from mutateFormDataBeforeCreate
Working on a little test learning Filament project.
It is an issue tracker. I have made an Issue model/resource, etc.
The issue has a user_id that is the user that created the issue.
I have the select box working on the resource that shows the users in the dropdown, etc. That works great.
I was trying to implement it so that if a user isn't selected, it will just pick the currently logged in user when saving.
I searched discord here and found an old post where they linked to the website and it mentioned adding
to the
CreateIssue.php
I added the if empty in hopes that it would only set the user if not given from the form.
It appears that it does create the issue without problem AND that it sets the user_id so that part looks good.
The issue is that sometime after the model actually saves and the 'save' succeeding from the perspective of the frontend, I get this:
I'm not sure why it would be trying to update the record that it just saved other than perhaps trying to set the updated_at
time? But in that case, why is the user_id null?
Perhaps it has old (submitted) data for the issue (before the mutate call)?2 Replies