How to use a Checkbox to edit fields in a related model
I've got a simple has-one relationship in my
User
model which relates to a UserFeatures
model, which has various fields that I'd like to edit with checkboxes in my UserResource
:
I've tried to do this using 'dot' notation to form a path, where feature_field
is one of the fields in UserFeatures
, like so:
However, this always returns a state of null.
So how can one create checkboxes to edit values in a 'has-one' related model?4 Replies
Maybe this :
Unfortunately that doesn't work, since it's a has-one relationship and the one record has many fields which need a checkbox for each field. The relationship method works only when there's a one-to-many relationship and each related record has a single value that gets a checkbox.
In my example,
feature_field
is only one of the boolean fields in the related record. It has about 20 boolean fields.Pretty sure it should work with a
HasOne
relationship...
https://filamentphp.com/docs/2.x/forms/layout#saving-data-to-relationships
Include all your checkboxes in the GroupAha I just noticed you're suggesting a group relationship. I was confusing it with the CheckboxList relationship. I'll give it a try, thanks!