Clicking on a child record in a table to take you to that record - not edit
I have a form edit for a Parent record that has Child records under it. This works well.
By default, when you click on a Child record in the table, it edits that record in a modal. I want to change that so that the page moves to the Child record in edit mode. I think something like this would work
->url("/childResourceName/childResourceNameId/edit")
, but to do that I would need a value for the childResourceNameId
and I don't know how to get that.
Or am I trying to code this, and there's a way to configure the Filament table to do this?
I've tried this example, but can't get the syntax correct:
Any advice on which way to attack this?5 Replies
I did figure out this hack, but it's ugly:
->url(fn(Person $record): string => '/admin/people/' . $record->person_id . '/edit')
This forms a URL off the people (the child) record.Generally if the child resource has an edit page the EditAction will direct to the page and not open a modal.
Also, don't use routes like that. Use
PersonResource::getUrl('edit', ['record' => $record])
Your closure will work in combination with the above code@Tonkawuck Ah - thanks! I will try this.
I'm confused as to where the
PersonResource::getUrl('edit', ['record' => $record])
should go. Is this inside the ->url()? Seems wrong.
Thanks for help on this. I'm been hacking at it all day.Yes, that function will return the route that you are currently constructing manually
Great, but my code looks like:
Does that go into the ->url()? If so, the $record variable isn't defined and errors out.
Sorry to be a newbie, but I'm really having trouble learning how to pull data in Filamnet. So much is abstracted (which is wonderful) that it leaves me wondering. I've watched all the videos I can find, but I'm still not getting it.
I think I got it!
->url(fn(Person $record): string => PersonResource::getUrl('edit', ['record' => $record]))
I didn't have the PersonResource defined in my use
statements.
Thanks!