Repeater basics
I'm sorry guys, I feel dumb asking. Maybe I'm over tired but I've been racking my brains in the docs and just can't see this simple thing.
I have a to_do model and in that model is a nullable invoice_id. So each task can be optionally attached to an invoice. In my invoice edit form I collect some other data but I want to attach multiple to_dos. I thought I'd use a repeater but it's trying to CREATE a new to_do. I just want to attach multiple to_dos that already exist to this new invoice I'm creating. Can I not use a repeater for this?
Cause this doesn't work. It tries to create a to_do.
2 Replies
SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value
INSERT INTO
to_dos
(invoice_id
, updated_at
, created_at
)
VALUES
(14, 2023 -10 -28 05: 26: 25, 2023 -10 -28 05: 26: 25)Sounds like its a BelongsToMany relationship.. docs clearly state that repeaters support
HasMany
& MorphMany
relationship types.
For BelongsToMany relationship you can use a Select
with ->multiple()
references:
https://filamentphp.com/docs/3.x/panels/resources/relation-managers
https://filamentphp.com/docs/3.x/forms/fields/select#integrating-with-an-eloquent-relationship