© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
aliaxon

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');
    }
}
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!!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Passing parent model to a child resource's create page
FilamentFFilament / ❓┊help
3y ago
Create child entries in RelationManager on view page of parent resource
FilamentFFilament / ❓┊help
2y ago
Create Comment - where to inject parent ID?
FilamentFFilament / ❓┊help
16mo ago
Get the parent id inside child repeater form
FilamentFFilament / ❓┊help
2y ago