Accessing parent resource when creating nested resource

Hi, When creating a new child resource from a relation manager's table on a parent resource, the new record will be automatically be attached to the parent you came from when creating the child as long as you don't add an input to select the parent. However, i wish to get some details about the parent you are adding this child to. How can i access these details? I know when editing, they are accessable via the $record, but is there another variable to get the parent while creating a nested resource. To hopefully make it a little more clear, this is my current code, which works perfectly when editing an existing child ("position") from the parent ("connector assembly") but offcourse, the $record value is not set when creating a new record; while it must be womehwere because it does know on submit which parent to assosiate the child with.
return $schema
->components([

Placeholder::make('connector_assembly_info')
->label('Connector Assembly')
->content(fn ($get, $record) => $record?->connectorAssembly?->connector?->name ?? 'Unknown')
->columnSpanFull(),
]);
return $schema
->components([

Placeholder::make('connector_assembly_info')
->label('Connector Assembly')
->content(fn ($get, $record) => $record?->connectorAssembly?->connector?->name ?? 'Unknown')
->columnSpanFull(),
]);
Solution:
managed to solve this by accesing livewire
$livewire->parentRecord
$livewire->parentRecord
...
Jump to solution
1 Reply
Solution
Mikavdwiel
Mikavdwiel5w ago
managed to solve this by accesing livewire
$livewire->parentRecord
$livewire->parentRecord

Did you find this page helpful?