Setting a default value for hidden fields
I have model which stores the user_id of the person who created each record. I don't want the user to see this field when interacting with the form - it should all happen behind the scenes.
The issue is that when I use:
I get an SQL error
SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value
.
Anyone know a solution for this?5 Replies
please do not do that
You have set it hidden so it will be dropped by livewire.
You want to mutate before save to apply the ID
thanks guys, wasn't aware of that functionality beforehand π
Essentially never render in the html and take that input for such a feature, because then the user could change user id. Ideally you could also put it as a method on boot for the model