Passing parent id to child create view
Hi there,
I have a parent child relations between Section and Certification model, hasMany and belongsTo functions are defined.
When I'm on SecionResource, Section is displayed as master and this "Create Certification" button is there.
I want to pass and add section_id into "data" variable when I open to modal so that I don't have to fillin the Section_id while creating the certification.
I add user_id as below:
class CreateCertification extends CreateRecord
{
protected static string $resource = CertificationResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['user_id'] = auth()->id();
return $data;
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
I wonder how to pass on the section_id and add it to $data so that the dropdown select with all sections is not needed when creation the certification record
Many thanks in advance!!0 Replies