© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•7mo ago•
9 replies
arthurpar

fillForm doesn't work while trying to test a Singular Resource

Hi,
I created a Singular Resource as explained here https://filamentphp.com/docs/4.x/resources/singular

My view is exactly the same as in the documentation and my page's form method is a little bit different since this page is here to create a new record instead of updating an existing one. Therefore I'm using
model
model
instead of
record
record
:

    /**
     * Configure the form for the page.
     */
    public function form(Schema $schema): Schema
    {
        return ContactForm::configure($schema)
            ->model(Contact::class)
            ->statePath('data');
    }
    /**
     * Configure the form for the page.
     */
    public function form(Schema $schema): Schema
    {
        return ContactForm::configure($schema)
            ->model(Contact::class)
            ->statePath('data');
    }

Here's how i'm testing the creation process:
it('can create', function (): void {
    $newData = Contact::factory()->make();

    $this->actingAs($newData->user);

    livewire(ContactUs::class)
        ->fillForm([
            'subject' => $newData->subject,
            'message' => $newData->message,
        ])
        ->call('create')
        ->assertHasNoFormErrors();

    $this->assertDatabaseHas(Contact::class, [
        'user_id' => $newData->user_id,
        'subject' => $newData->subject,
        'message' => $newData->message,
    ]);
});
it('can create', function (): void {
    $newData = Contact::factory()->make();

    $this->actingAs($newData->user);

    livewire(ContactUs::class)
        ->fillForm([
            'subject' => $newData->subject,
            'message' => $newData->message,
        ])
        ->call('create')
        ->assertHasNoFormErrors();

    $this->assertDatabaseHas(Contact::class, [
        'user_id' => $newData->user_id,
        'subject' => $newData->subject,
        'message' => $newData->message,
    ]);
});


but I get this error when the
fillForm
fillForm
method is called:
  FAILED  Tests\Feature\Pages\ContactUsPageTest > it can create                                                                         Error   
  Call to a member function getDefaultTestingSchemaName() on null

  at vendor/filament/forms/src/Testing/TestsForms.php:30
     26▕             if ($this->instance() instanceof HasActions) {
     27▕                 $form ??= $this->instance()->getMountedActionSchemaName();
     28▕             }
     29▕ 
  ➜  30▕             $form ??= $this->instance()->getDefaultTestingSchemaName();
     31▕ 
     32▕             /** @phpstan-ignore-next-line */
     33▕             $this->assertSchemaExists($form);
     34▕ 

      +3 vendor frames 
  4   tests/Feature/Pages/ContactUsPageTest.php:30
  FAILED  Tests\Feature\Pages\ContactUsPageTest > it can create                                                                         Error   
  Call to a member function getDefaultTestingSchemaName() on null

  at vendor/filament/forms/src/Testing/TestsForms.php:30
     26▕             if ($this->instance() instanceof HasActions) {
     27▕                 $form ??= $this->instance()->getMountedActionSchemaName();
     28▕             }
     29▕ 
  ➜  30▕             $form ??= $this->instance()->getDefaultTestingSchemaName();
     31▕ 
     32▕             /** @phpstan-ignore-next-line */
     33▕             $this->assertSchemaExists($form);
     34▕ 

      +3 vendor frames 
  4   tests/Feature/Pages/ContactUsPageTest.php:30
Singular resources - Resources - Filament
Solution
are you sure that you are authorized to view the component?
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Singular Resource: Just doesn't work
FilamentFFilament / ❓┊help
3mo ago
Filter test FAILED `filterTable` doesn't work
FilamentFFilament / ❓┊help
13mo ago
In a test, should fillForm() be firing afterStateUpdated()?
FilamentFFilament / ❓┊help
2y ago
Configurable string prefix to singular resource model name
FilamentFFilament / ❓┊help
3y ago