Relation Manager: How to customize edit action?

Given the following example of a form in a relation manager:
public function form(Form $form): Form
    {
        return $form
            ->schema([
                Checkbox::make('allowAllExtensions')
                    ->label(__('templates.allow_all_extensions'))
                    ->live()
                    ->dehydrated(false)
                    ->afterStateUpdated(function (Set $set) {
                        $set('allowed_file_extensions', ["*"]);
                    }),
                Repeater::make('allowed_file_extensions')
                    ->hidden(fn (Get $get) => $get('allowAllExtensions') === true)
                    ->label(__('templates.allowed_file_extensions'))
                    ->hint(__('templates.allowed_file_extensions_hint'))
                    ->simple(
                        TextInput::make('extension')
                            ->string()
                            ->regex('/^([a-zA-Z0-9]+)$/u')
                            ->required(),
                    ),
            ]);
    }


How can I hook into the updating process of the edit action of the form? A lot of the docs only mention resource pages and not the relation manager itself.

What I want to achieve:
  • Set the pivot model's attribute to ['*'] if the checkbox is selected. I tried it using afterStateUpdated but that doesn't work.
I think I need to hook into the form's lifecycle but it seems like a Relation Manager does not have anything like https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-saving nor https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-the-saving-process. Also this https://filamentphp.com/docs/3.x/actions/prebuilt-actions/edit#customizing-the-saving-process doesn't work, because the EditAction is only indirectly used in the form method of the Relation Manager?
Was this page helpful?