Form
This project leverages Laravel's Blade components (x-components) to build a dynamic and reusable form component system. It allows developers to create consistent UI forms with minimal repetition while maintaining flexibility and extensibility.
📄 x-xf::form
📘 Description
The x-xf::form component is part of a modular and dynamic form-building system in Laravel using Blade components. It is designed to make form creation more maintainable, DRY (Don't Repeat Yourself), and developer-friendly by abstracting common tasks such as:
- Setting up form actions using route names or custom URLs
- Automatically binding model data to input fields
- Enabling file upload functionality when needed
- Supporting advanced HTTP methods (PUT, PATCH, DELETE)
- Providing built-in CSRF protection
- Offering a clean, reusable, and consistent syntax
This component acts as a form wrapper, allowing developers to construct flexible and powerful forms with minimal repetitive code. It integrates smoothly with child components (like x-xf::input, x-xf::select, etc.), supports value retention using Laravel's old() helper, and enhances form maintainability in large-scale applications.
🔒 The form automatically includes the @csrf directive to protect against cross-site request forgery.
The <x-xf::form> component is a reusable Blade form wrapper designed for dynamic and consistent form generation. It supports model binding, flexible configuration via attributes, and file upload handling.
✅ Usage Example
<x-xf::form :model="$user1" :attr="['route' => 'post.data', 'method' => 'PUT']">
<!-- Form fields go here -->
</x-xf::form>
| Key | Type | Description |
|---|---|---|
model |
model |
Pass collection to auto populate data |
route |
string |
Named route for form action (e.g., 'users.store') |
url |
string |
Direct URL (used only if route is not set) |
method |
string |
HTTP method: 'GET', 'POST', 'PUT', 'PATCH', 'DELETE' (default: POST) |
file |
bool |
Enables file uploads by setting enctype="multipart/form-data" |
others |
Can pass anyother attribute as an array format |