Select default is acting up
I'm trying to select a default value based on which field is filled:
but it always selects the same field, how can i fix this?
5 Replies
Two things. $model should be $record. And default only works on create which means there is no record yet so it would just be ‘total’ regardless as the default.
hmm okay, but this is not a database field, since it's just a nice ui thing
does it also not work if the value is not in the record?
default only works on create, which has no record.
on edit the default will already have a value therefore default is redundant.
okay
i guess i need to modify the data then, shouldn't be to big of an issue
if you need to change it on edit base on the record you need to look into afterStateHydrated() to set it to what you want.