The Filament Form Faker is a utility package designed for generating fake input data in Filament v3 forms. It's ideal for streamlining the development of extensive forms and conducting thorough form testing.
Note
This package is not recommended for production use and should be limited to development and testing scenarios.
This package is currently in its Beta phase. Your participation in testing and feedback through issue reporting is highly appreciated.
You can install the package via composer:
composer require innoge/filament-form-faker --dev
To autofill forms with fake data in Filament Record Pages, use
the InnoGE\FilamentFormFaker\Traits\FillsFormWithFakeData
trait. Below is an example for
the CreateUser of the UserResource page:
<?php
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use Filament\Resources\Pages\CreateRecord;
use InnoGE\FilamentFormFaker\Traits\FillsFormWithFakeData;
class CreateUser extends CreateRecord
{
use FillsFormWithFakeData;
protected static string $resource = UserResource::class;
}
By default, forms are filled with fake data only in local or testing environments. This behavior can be customized by
overriding the shouldFillFormWithFakeData
method in your Page Component.
protected function shouldFillFormWithFakeData(): bool
{
// insert your custom logic here
}
When you are using Filament/Forms
outside of the Panel Builder you can use the fake()
method on your Form instance to
fill your form with fake data. We recommend using this method in your mount
method.
public function mount()
{
$this->getForm('form')->fake();
// or
$this->form->fake();
}
Currently, we support the following field types:
- Builder
- Checkbox
- CheckboxList
- KeyValue
- Option
- Repeater
- Select
- Textarea
- TextInput
If you want to add support for other field types please create an issue or a pull request.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.