© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
cj

Passing values to CreateAction for form population

I have a relationmanager with the CreateAction in the header. I would like to populate the resulting form with data from the parent class, but I can't seem to figure out the process. I've tried setting the form data in a variety of ways, but nothing seems to pass on to the resulting form. In the code below, I'm trying to populate the TextInput for the 'name' field. Can someone point me in the right direction?

public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name'),
            ]);
    }

public function table(Table $table): Table
    {
        $table = MyResource::table($table);

        return $table
            ->filters([])
            ->headerActions(actions: [
                Tables\Actions\CreateAction::make()
                    ->formData([
                        'name' => 'hoo', // nope, doesn't work
                    ])
                    ->mutateFormDataUsing(function (array $data): array {
                        \Log::info('mutateFormDataUsing: never gets called');
                        $data['name'] = 'goo';

                        return $data;
                    })
                    ->beforeFormFilled(function () {
                        \Log::info('beforeFormFilled: called, but doesn\'t seem to do anything');
                        $data['name'] = 'foo';

                        return $data;
                    })
                    ->modalWidth('7xl')
                    ->createAnother(false),
            ]);
public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name'),
            ]);
    }

public function table(Table $table): Table
    {
        $table = MyResource::table($table);

        return $table
            ->filters([])
            ->headerActions(actions: [
                Tables\Actions\CreateAction::make()
                    ->formData([
                        'name' => 'hoo', // nope, doesn't work
                    ])
                    ->mutateFormDataUsing(function (array $data): array {
                        \Log::info('mutateFormDataUsing: never gets called');
                        $data['name'] = 'goo';

                        return $data;
                    })
                    ->beforeFormFilled(function () {
                        \Log::info('beforeFormFilled: called, but doesn\'t seem to do anything');
                        $data['name'] = 'foo';

                        return $data;
                    })
                    ->modalWidth('7xl')
                    ->createAnother(false),
            ]);
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

Fill form in CreateAction
FilamentFFilament / ❓┊help
7mo ago
createAction inside form section
FilamentFFilament / ❓┊help
3y ago
Pass parameter from RelationManager createAction to form
FilamentFFilament / ❓┊help
2y ago
FileUpload: Default values for edit Form
FilamentFFilament / ❓┊help
10mo ago