Download the PHP package occ-therapist/form-request-validation-for-filament without Composer
On this page you can find all versions of the php package occ-therapist/form-request-validation-for-filament. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download occ-therapist/form-request-validation-for-filament
More information about occ-therapist/form-request-validation-for-filament
Files in occ-therapist/form-request-validation-for-filament
Package form-request-validation-for-filament
Short Description Use Laravel Form Request validation rules inside Filament schemas.
License MIT
Informations about the package form-request-validation-for-filament
Form Request Validation for Filament
Use Laravel Form Request validation inside Filament — define your rules, messages, and attributes once, reuse them across API routes, controllers, and Filament UI.
Why this plugin?
Filament validates fields through dedicated methods like ->required() and ->email() on each input. That works well for simple forms, but validation logic often belongs in a central place — especially when the same rules already exist in a Form Request.
This plugin bridges that gap: attach a Form Request to your schema or table filters and its validation rules are automatically applied to the matching fields.
Features
- Form Request integration —
rules(),messages(),attributes(), andprepareForValidation() - Automatic field mapping — by field name, dot notation, and wildcards (
items.*.name) - Array & pipe syntax —
'email' => ['required', 'email']and'email' => 'required|email' - Context-aware — different Form Requests per page via callback (create vs. edit)
- Dynamic rules — re-resolved on every validation (
required_if,Rule::unique(), etc.) - Request simulation — route parameters and input context for Form Requests
- Smart rule merging — Form Request rules take precedence on conflicts
- Orphan rule handling — unmatched rules show a Filament notification
getFormRequestValidated()— optional helper trait for validated data- Filament 4 & 5 — single package, internal adapter layer
Supported contexts
| Context | API |
|---|---|
| Resource Create / Edit | Schema::formRequest() |
| Standalone forms / Settings pages | Schema::formRequest() |
| Action modals | Schema::formRequest() |
| Wizards (per-step validation) | Schema::formRequest() |
| Relation managers | Schema::formRequest() |
| Table filters | Table::filtersFormRequest() |
Requirements
| Dependency | Version |
|---|---|
| PHP | 8.2+ |
| Laravel | 12 or 13 |
| Filament | 4.x or 5.x |
Installation
Auto-registers via Laravel package discovery. No manual setup required.
Quick start
1. Create a Form Request
2. Attach it to your Filament schema
Important: Call
->formRequest()after->components()so the validation hook is appended correctly.
Validation errors appear directly on the matching input fields.
API reference
Schema::formRequest()
| Parameter | Type | Required | Description |
|---|---|---|---|
class |
Closure |
Yes | Returns the Form Request class. Receives $livewire via dependency injection. |
mergeInput |
Closure |
No | Merges additional data into the simulated request input. Receives $state and $livewire. |
Context selection
Enriching input data
Useful when Form Requests depend on record data, route parameters, or values not visible in the form.
prepareForValidation()
Runs on the simulated Form Request before rules() are read. Use it to normalize or enrich input that rules() (or getFormRequestValidated()) depends on:
Prepared input is stored for getFormRequestValidated(). Filament still validates the visible form state against the extracted rules — transforms here do not rewrite Livewire field values.
Table::filtersFormRequest()
Same parameters as Schema::formRequest(). Attaches validation to the table's filter form.
| Filter mode | When validation runs |
|---|---|
| Deferred (default) | When the user clicks Apply |
Live (->deferFilters(false)) |
On every filter change |
Usage by context
Resource pages
Action modals
Wizards
One Form Request for the entire wizard — attach it to the root schema:
Only fields in the active step are validated per step. Use mergeInput if rules depend on data from other steps:
Relation managers
For modal actions on the table, attach formRequest() inside the action's schema callback.
Table filters
Field mapping
Rules are matched to fields automatically by name — no per-field configuration needed.
| Form Request key | Filament field | Match type |
|---|---|---|
email |
TextInput::make('email') |
Exact |
address.street |
TextInput::make('address.street') |
Dot notation |
items.*.name |
Repeater child TextInput::make('name') |
Wildcard |
created.from |
Filter field DatePicker::make('from') in Filter::make('created') |
Dot notation |
State path normalization
Filament uses prefixed state paths internally. The plugin strips these automatically:
| Internal state path | Resolved key |
|---|---|
data.email |
email |
mountedActions.0.data.email |
email |
tableDeferredFilters.created.from |
created.from |
Rule merging
When a field already has Filament validation rules, both sets are merged:
Result: string, required, email, unique:users
- Form Request rules take precedence on conflicts (
nullablevs.required) - Identical rules are deduplicated
- Non-conflicting field rules are kept
Orphan rules
Rules without a matching schema field still run on submit. Failures show a Filament notification instead of an inline field error.
To show the error on a field, add a matching input (visible or hidden):
Accessing validated data
How it works
Limitations
| Form Request feature | Status |
|---|---|
rules() |
Supported |
messages() |
Supported |
attributes() |
Supported |
prepareForValidation() |
Supported — runs before rules(); prepared input used by getFormRequestValidated() (does not rewrite Livewire field values) |
authorize() |
Not supported — use Filament policies |
withValidator() |
Not supported — Filament owns the validator lifecycle |
passedValidation() / failedValidation() |
Not supported |
Testing
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
License
MIT © occTherapist
All versions of form-request-validation-for-filament with dependencies
filament/filament Version ^4.0|^5.0
illuminate/contracts Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/validation Version ^12.0|^13.0
spatie/laravel-package-tools Version ^1.16