Please Help - Form Action

class Settings extends Page implements HasForms { use InteractsWithForms; protected static ?string $navigationIcon = 'heroicon-o-document-text'; protected static string $view = 'filament.pages.settings'; public function mount() { $companyDetails = CompanyDetail::find(1); $this->form->fill([ 'company_name' => $companyDetails->company_name ?? '', 'address' => $companyDetails->address ?? '', 'telephone' => $companyDetails->telephone ?? '', 'email' => $companyDetails->email ?? '', ]); } public function form(Form $form): Form { return $form ->schema([ TextInput::make('company_name') ->label('Company Name') ->required(), Textarea::make('address') ->label('Company Address') ->required(), TextInput::make('telephone') ->label('Tel No.') ->tel() ->telRegex('/^[+][(]{0,1}[0-9]{1,4}[)]{0,1}[-\s./0-9]$/') ->required() ->reactive(), TextInput::make('email') ->label('E-mail') ->email() ->required(), ]); } public function getFormActions() { Action::make('save') ->label('Save Settings') ->submit('save') ->color('primary'); }
public function save() { // Get form data $data = $this->form->getState();

CompanyDetail::updateOrCreate( ['id' => 1], $data ); session()->flash('success', 'Settings have been saved successfully!'); } } Error TypeError count(): Argument #1 ($value) must be of type Countable|array, null given
4 Replies
shandias
shandiasOP3w ago
@Dennis Koch
Dennis Koch
Dennis Koch3w ago
Yo, please read #✅┊rules and #⚠ READ BEFORE POSTING
shandias
shandiasOP3w ago
Applogized
LeandroFerreira
Shouldn't you return the action in the getFormActions method? If you are using this method as Filament, you should return an array of your actions...
Want results from more Discord servers?
Add your server