All Blade Forms components are designed to work as close to native HTML inputs as possible. This makes them directly interchangeable, including automatic error handling.
As you might have notice we didn't supply a CSRF token input. This is automatically handled by the x-form component. Additionally, for PUT and PATCH requests, the method will automatically be spoofed as described in the Laravel Documentation.
Alpine.js and Livewire require the usage of the x-model or wire:model attribute instead of the standard name attribute. Blade Forms automatically detects their usage and ensures error messages are correctly displayed.
<divx-data="{ name: $wire.entangle('name') }"><x-formwire:submit.prevent="save"><!-- Entangled input using Alpine.js --><x-form-inputx-model="name"label="Name"/><!-- Wired input using Livewire directly --><x-form-inputwire:model="description"label="Description"/><x-btntype="submit">Store</x-btn></x-form></div>
Blade Forms automatically handles Laravel Error Messages and displays any related error messages underneath the input.
When using normal Laravel Request you will most likely want to keep the old input data when a validation error occurs. Instead of using something like value="old('name')" Blade Forms will automatically repopulate any previously entered data for you.
By default any validation error messages are resolved using the name, x-model or wire:model attribute.
In some cases, especially with Alpine.js where you might have used a masked input, your validation error message key might not directly relate to any of these attributes.
To resolve this you can customize the validation error message key by supplying the error-name attribute:
By default all components except radio's show any validation error messages. To disabled this behavior you can supply the show-errors="false" boolean attribute to disable error messages.