FilamentF
Filament12mo ago
Matthew

Validate on suffixAction

I've got a form that is mostly visual, and only a couple of editing points, and doesn't have a general submit.

I thought I could be clever where I wanted a field to be editable in that view, by having a suffix Action acting as a save button for that field.

                FormField::telephone('rf_referee_telephone')
                    ->columnSpan(1)
                    ->live()
                    ->suffixAction(
                        Action::make('saveTelephone')
                            ->icon('heroicon-m-cloud-arrow-up')
                            ->tooltip('Save Telephone')
                            ->action(function ($record, $get) {

                                $record->rf_referee_telephone = $get('rf_referee_telephone');
                                $record->save();

                                Notification::make()
                                    ->title('Telephone Saved')
                                    ->success()
                                    ->send();
                            })
                            ->visible(function ($record, $get) : bool {

                                return $record->rf_referee_telephone !== $get('rf_referee_telephone');

                            })

                    ),


Works fine, but there is no validation run. Is there a command I can have within the action to run the field validation prior to the save?

Cheers
Was this page helpful?