Retrieve ID of selected child from related table

Hello everyone, I can't retrieve the id of the table related to the Resource, is there any way? Ex: I have a Questions Resource and it has a Relationship with Options. When I edit a Question it lists all the Options, so far ok. I'm doing a custom action on the relationship, and I would like to retrieve the id of the record I'm clicking on. When I use $this->getOwnerRecord() I am retrieving the id of the Father, is there a way to retrieve the id of the selected child?
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('questions')->label('')->icon('heroicon-o-question-mark-circle')
->action(
fn () => redirect()->route('filament.admin.resources.onboarding.show-questions', [$this->getOwnerRecord(), ?])
),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\Action::make('questions')->label('')->icon('heroicon-o-question-mark-circle')
->action(
fn () => redirect()->route('filament.admin.resources.onboarding.show-questions', [$this->getOwnerRecord(), ?])
),
])
My route/page expects two parameters, I send the first with $this->getOwnerRecord(), but the second, which would be the id of the selected line, I cannot retrieve. Thanks.
1 Reply
marcosmarcolin
marcosmarcolin8mo ago
I found it, I can retrieve it with: $this->mounted Table ActiveRecord. Solved.