TALL-forms
Autogenerated and Headless Livewire form components
This is the documentation for Tall-forms v8
Requirements
Php ^8.0|^8.1
Laravel ^8.75.0
Livewire ^2.8.1
Alpine ^3.5.1
Tailwind 2.x or 3.x
Autogenerated or Headless
(Extend TallFormComponent)
In a standard TallFormComponent. You don't need to add properties, render(), $rules or create a blade view.
<?php
namespace App\Http\Livewire\Forms;
use App\Models\Post;
use Tanthammar\TallForms\Input;
use Tanthammar\TallForms\Textarea;
use Tanthammar\TallForms\TallFormComponent;
class PostForm extends TallFormComponent
{
public function mount(Post $post): void
{
$this->mount_form($post);
}
protected function fields(): array
{
return [
Input::make('Title')->rules('required|string|min:6'),
Textarea::make('Content')->rules('required|string|max:500')
];
}
}No view needed
(Extend native Livewire Component)
When you want to create your own blade view and design the component, following Livewire conventions.
You don't have to use an Eloquent Model instance, this is just an example.
Declare the fields in the blade view
resources/views/livewire/post-form.blade.php
Wrapping fields with labels
See Blade components, "Label wrapper" page
(Extend TallFormFields)
This form type is almost the same as Headless. The difference is that you declare the fields in the Livewire Component instead of the blade view.
Make a Livewire component that extends TallFormFields and design the component, following Livewire conventions.
You don't have to use an Eloquent Model instance, this is just an example.
@include('tall-forms::fields-only')
When you extend TallFormsFields , the form view must contain the blade directive that renders the form fields:
resources/views/livewire/post-form.blade.php
TallFormFields properties
The TallFormFields component only contains minimum functionality to render the fields and it uses the "Headless" way to generate field html.
There are only a few properties in TallFormFields that you can override with the formAttr() method.
Last updated
Was this helpful?