© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Ron

How to test Header/Footer Actions in a Section Form Component

callFormComponentAction fails with error "Call to a member function getKey() on null" when attempting to test calling a section header action.

Can callFormComponentAction() be used to test Header/Footer actions on Form Sections.

Test Code:
it('can toggle form edit', function () {
    $order = $this->getOrders(1);

    // Arrange
    livewire(OrderRentalHistory::class, ['record' => $order->id])
        ->assertFormFieldIsDisabled('address')
        ->callFormComponentAction('rental-history', 'edit-form')
        ->assertFormFieldIsEnabled('address');

});
it('can toggle form edit', function () {
    $order = $this->getOrders(1);

    // Arrange
    livewire(OrderRentalHistory::class, ['record' => $order->id])
        ->assertFormFieldIsDisabled('address')
        ->callFormComponentAction('rental-history', 'edit-form')
        ->assertFormFieldIsEnabled('address');

});

Form Code:
Section::make('Rental History')
                ->key('rental-history')
                ->headerActions([
                    Action::make('edit-form')
                        ->label('Edit')
                        ->button()
                        ->icon('mdi-pencil')
                        ->action(fn (Get $get, Set $set) => $set('form-editable', ! $get('form-editable'))),
                ])
                ->schema([
                    Hidden::make('form-editable')
                        ->live(),
                    TextInput::make('address')
                        ->prefixIcon('mdi-map-marker')
                        ->disabled(fn (Get $get) => ! $get('form-editable')),

                ]),
Section::make('Rental History')
                ->key('rental-history')
                ->headerActions([
                    Action::make('edit-form')
                        ->label('Edit')
                        ->button()
                        ->icon('mdi-pencil')
                        ->action(fn (Get $get, Set $set) => $set('form-editable', ! $get('form-editable'))),
                ])
                ->schema([
                    Hidden::make('form-editable')
                        ->live(),
                    TextInput::make('address')
                        ->prefixIcon('mdi-map-marker')
                        ->disabled(fn (Get $get) => ! $get('form-editable')),

                ]),
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

Testing Section header/footer Actions
FilamentFFilament / ❓┊help
3mo ago
How to test modal footer actions
FilamentFFilament / ❓┊help
9mo ago
Move Header Actions to Footer
FilamentFFilament / ❓┊help
2y ago
Section has no footer actions?
FilamentFFilament / ❓┊help
2y ago