© 2026 Hedgehog Software, LLC

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

Testing form data for a simple resource (Filament v3).

Gooday, I hope someone can help me.

I am writing a test to check the form data is valid on a resource created with the --simple option. The following code is an example and works as expected:

php 
livewire(CityResource\Pages\ManageCities::class)
        ->mountAction('create')
        //Check that all fields are required
        ->setActionData([
           'state'=>null,
            'name' => null
          ])
        ->callMountedAction()
        ->assertHasActionErrors(['state' => ['required'], 'name' => ['required'])]);
php 
livewire(CityResource\Pages\ManageCities::class)
        ->mountAction('create')
        //Check that all fields are required
        ->setActionData([
           'state'=>null,
            'name' => null
          ])
        ->callMountedAction()
        ->assertHasActionErrors(['state' => ['required'], 'name' => ['required'])]);

In the modal form the name field is disabled until a state has been chosen. I want to extend this code to check that the name field is disabled. If I use ->assertFormFieldIsEnabled('name') I get an error:

Filament\Resources\Pages\ListRecords::form(): Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given.

This code above is merely an example and my actual form has more fields which I'd like to check using the built-in form testing functions but not sure how to get around this error. Your help is appreciated.
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

Using a Livewire form inside a Filament Resource (simple)
FilamentFFilament / ❓┊help
3y ago
Preload Resource data for form
FilamentFFilament / ❓┊help
3y ago
Filament v3 Resource does not fill the Edit form
FilamentFFilament / ❓┊help
3y ago
Wireframing for Filament v3
FilamentFFilament / ❓┊help
2y ago