© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
ngaiza_287

repeater field test

please assist, am trying to check if a field in the repeater can through error if not available, and how i can use file in pest test to fill the field for testing. Here is a rough idea of what am trying to do.

The class


class Add extends Component implements HasForms
{
    use InteractsWithForms;

    public $name = '';

    public $phone_number = '';

protected function getFormSchema(): array
    {
        return [
            TextInput::make('name')
                ->label('Full name')
                ->required(),

            Repeater::make('phones')
                ->relationship()
                ->schema([
                    TextInput::make('phone_number')
                        ->label('Phone Number')
                        ->hint('E.g: 255713001001 or 0713001001')
                        ->required(),
                ])
                ->label('Phone numbers')
                ->defaultItems(1)
                ->minItems(1)
                ->createItemButtonLabel('Add user phone number'),
        ];
    }
}
class Add extends Component implements HasForms
{
    use InteractsWithForms;

    public $name = '';

    public $phone_number = '';

protected function getFormSchema(): array
    {
        return [
            TextInput::make('name')
                ->label('Full name')
                ->required(),

            Repeater::make('phones')
                ->relationship()
                ->schema([
                    TextInput::make('phone_number')
                        ->label('Phone Number')
                        ->hint('E.g: 255713001001 or 0713001001')
                        ->required(),
                ])
                ->label('Phone numbers')
                ->defaultItems(1)
                ->minItems(1)
                ->createItemButtonLabel('Add user phone number'),
        ];
    }
}


The test


livewire(Add::class)
        ->call('invite')
        ->assertHasErrors(['name',  'phone_number']);
livewire(Add::class)
        ->call('invite')
        ->assertHasErrors(['name',  'phone_number']);
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

Dynamic Repeater Field
FilamentFFilament / ❓┊help
2y ago
Repeater unique field
FilamentFFilament / ❓┊help
3y ago
how to test Repeater
FilamentFFilament / ❓┊help
3y ago