Action button in View Resource to Show Create Popup based on Relationship Manager
I have an Employee resource with work_histories in relationship manager.
I want to have an action button in the View Employee Resource which when click, will open the popup that is similar to the form for creating new work history in the relationship manager.
What should I put in the URL / function when I create Action::make() ?
Thanks!
Solution:Jump to solution
@setiawanh The URL for the resource of WorkHistoryResource would be
WorkHistoryResource::getUrl('create')
but as I understand you don't need the URL (and you may not even have a separate resource), you need to open the create form, so that is not the same, that wouldn't work.
Can't you just show Relationship Manager in the View Employee Resource and it would contain that button?...4 Replies
Solution
@setiawanh The URL for the resource of WorkHistoryResource would be
WorkHistoryResource::getUrl('create')
but as I understand you don't need the URL (and you may not even have a separate resource), you need to open the create form, so that is not the same, that wouldn't work.
Can't you just show Relationship Manager in the View Employee Resource and it would contain that button?I don't think you need the url() method.
You could just add a Filament\Actions\CreateAction to the headerActions of the view page and load the form for the desired resource. Just remember to also add the model() method with the respective resource model class.
I did something similiar but not sure if this suits you:
@PovilasKorop thanks. In the end, I have tried to create a filament resource for EmployeeWorkHistory by itself and point the URL to there with prepopulated employee. Will see how this works π Thanks!
Thank you... getForm() as not found. What class is "Organization"?
This is an example code I presented. Organization is one of my models which loads the form schema on the getForm() method. You should pass your own resource form schema and model.