sven
Custom action before EditRecord
Hi, I want to show an Action to the user when they want to publish a record. More specifically, I have a Collection model, and an Article model. A Collection has many articles. When the user wants to publish the collection, I want to show a modal to select articles to publish along with the collection.
I'd like to show a modal that lets the user select the associated articles to publish with the collection. At the moment the user has to select the article records in the relation manager and publish them there. I'd like to integrate those two actions.
I tried different things but can't figure out from the docs if this would be possible as there seem to be quite a lot of functions to tap into, along with custom actions etc. Any help?
3 replies
Validate MorphedByMany pivot table
I have a many-to-many polymorphic Author (authorable) relation in my schema. The pivot table also has a role_id that links to an author_roles table. In my ArticleResource I now built a relation manager between the Article model and Author relation.
The idea is that users can attach Authors and specify the AuthorRole in an AttachAction on the relation manager.
It's possible to add an author to the same record multiple times, but not with the same role. (eg. The author could be both an writer and editor of the article.)
I now want to write a Unique validation rule to check that the author_id, authorable_type, authorable_id, AND author_role_id are unique.
I'm struggling to understand where to get the data and how to access the pivot data to enforce the unique validation rule.
Another possibility could be not to show the duplicate option in the first place, or disable it. But I'm not sure how to get the pivot data from Filament
This is what I have so far..
2 replies
Using SpatieMediaLibraryFileUpload in form tabs
When I try to add the SpatieMediaLibraryFileUpload form component to a Filament\Forms\Components\Tabs\Tab component I get the following error: "Filament\Forms\Components\SpatieMediaLibraryFileUpload::Filament\Forms\Components{closure}(): Argument #2 ($file) must be of type string, array given".
Can anyone help me with this?
Here is the full code I'm trying to implement:
4 replies