FilamentF
Filament3y ago
Finn

Modify relationship data before inserting/creating

So I do have a resource, with a form with multiple text inputs.
In that form I made a fieldset that links to a relation

Forms\Components\Fieldset::make(self::$relationName)
                    ->relationship(self::$relationName)
                    ->label('Pagina informatie')
                    ->schema([
                        Forms\Components\TextInput::make('meta_title')
                             ->label('Meta title')
                             ->required(),
                        Forms\Components\TextInput::make('meta_description')
                             ->label('Meta description')
                             ->required(),
                    ])


As you can see, in there I have 2 inputs in there. Now when I click on create in Filament, I want to modify the data from the text input.
Normally I would modify the data in the app\Filament\Resources\MyResource\Pages\CreateMyResourcePage.php using the mutateFormDataBeforeCreate(array $data) method.
But in the $data of the mutateFormDataBeforeCreate method, I do not have access to the relationship properties aPES_Think

So how would I modify it?
Was this page helpful?