Attach Option Form...?

According to the docs (https://filamentphp.com/docs/2.x/forms/fields#creating-new-records), I can use createOptionForm() for a BelongsTo relationship. Is it possible to do something like attachOptionForm() for a BelongsToMany relationship, allowing the user to set values for the many-to-many intermediate/pivot table...? If so, any docs/links/examples...? If not, any advice/suggestions on how to allow a user to attach many-to-many relationships (with pivot attributes) when creating/editing...?
Filament
Fields - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
10 Replies
Patrick Boivin
Experimenting with the Repeater field here : https://discord.com/channels/883083792112300104/1116402597335674950 Super curious to know if anyone has a better solution in terms of UI/UX
awcodes
awcodes2y ago
#awcodes-table-repeater maybe.
Patrick Boivin
Cool! I like how compact it is.
Travis
TravisOP2y ago
Thx. I may take a look. Is this basically the repeater with a nicer UI/UX...?
awcodes
awcodes2y ago
yea, it's just an extension of the Repeater with a different layout
Travis
TravisOP2y ago
Hey....are you aware of a way to ignore validation on an empty repeater item...? I have some of the repeater fields set as required, but the user is not required to add items. So, do you know how I can ignore "empty" or unfilled items...?
awcodes
awcodes2y ago
Not quite following what you’re asking.
Dan Harrin
Dan Harrin2y ago
->defaultItems(0) ?
Travis
TravisOP2y ago
Sorry. OK. So, I have the repeater in my form. I have it show one "item", which it does by default. But, if the user doesn't enter any data for the default item, then it will fail certain validation. From a UX standpoint, it feels good to have an empty, ready-to-go item to fill out, but it also feels bad to invalidate an empty one if zero items are required. An example might be special events for some resource. By default, the repeater would show one empty special event item. It might require a date and a description. If the user submits the form without entering any special event data, then the form will say that the date/description are required and must be filled out. By using ->defaultItems(0), as @Dan Harrin has suggested, then this problem is avoided, but then the user has to manually click "add an item". (This isn't terrible, by the way, but it's something I'd rather avoid....if possible.) So, I'm asking if you know of a way to ignore validation for repeater items that haven't been filled out at all....? 🤔 Hope that makes (more) sense.... 🤓
awcodes
awcodes2y ago
Ok. Yea. That kinda goes against the logic of a required field though. You could try a required if or a custom validation rule. But I don’t think there is an easy way to do that out of the box.
Want results from more Discord servers?
Add your server