Cascading/conditional form on polymorphic relations?
I have a model where I created two polymorphic nullable relations to change the 'nature' of an order based on what type of product it is. The company has two main types of products, one in a book-like album form, one as a single print item.
Thus the OrderItem model can have either an albumitemable or printitemable morph that adds the respective properties for the album and print variations.
Now I'm trying to add this to the orderitem form.
So basically I need a selector or perhaps radio-box elements that allow a user to select if it's an album or a print product, then have the associated properties (form elements) show for that type.
The filament documentation is so piecemeal I can't even seem to find anything that tells me how to add something so simple as a form field that won't be attempted to be saved, no less figure out how to use that field to show/hide other element groups in the form.
Any help is appreciated.
2 Replies
ok, why can't I see the post content anymore? This discord interface is as bad as the filament documentation.
to hide/show an input:
https://filamentphp.com/docs/3.x/forms/advanced#the-basics-of-reactivity
and
https://filamentphp.com/docs/3.x/forms/advanced#reactive-forms-cookbook
to prevent saving an input:
https://filamentphp.com/docs/3.x/forms/advanced#preventing-a-field-from-being-dehydrated
worth reading the
Field lifecycle
to understand more you will need it for hide/show stuff too