Switching from Nova to FIlament, questions on relation manager

When using relation manager, it looks like you have to re-create new/edit forms that may already be present on the relationship resource itself? Is there anyway when you click on a BelongsTo in the related table to simply use the form already created for that original resource instead of having to keep two separate copies of it? Or better yet, the edit button will bring up the original edit page for that resource (same with new)? This is how it works on Nova anyway, just trying to wrap my head around it here.
9 Replies
toeknee
toeknee2y ago
You can generalise the form build and just call the form wherever you want too?
Dan Harrin
Dan Harrin2y ago
You can forward the form/table from the relation manager to the resource
public static function form(Form $form): Form
{
return MyResource::form($form);
}
public static function form(Form $form): Form
{
return MyResource::form($form);
}
and then hide the parent_id field in the form, as we handle that for you
Select::make('parent_id_field')
->hiddenOn(RelationManagerClassHere::class)
Select::make('parent_id_field')
->hiddenOn(RelationManagerClassHere::class)
This is one of the ways that Filament works very differently from Nova - all code is fully exposed by default, then you can drill down and abstract things to your liking.
pepperoni dogfart
Let me give that a go, thanks works the same for table too, awesome thank you exactly what I was looking for
Dan Harrin
Dan Harrin2y ago
your username is pure poetry btw how beautiful
pepperoni dogfart
hahaha
pepperoni dogfart
along the same idea, anyway to call existing actions from the other resource? was playing around with MyResource::table($table)->actions() can't figure it out tho
awcodes
awcodes2y ago
create a method on your resource to return the array of actions, then you can call it in any place you want. even in the resource
Dan Harrin
Dan Harrin2y ago
table ->actions() should be inherited as normal from the resource to the relation manager what specifically is wrong
Want results from more Discord servers?
Add your server