Headless

Sometimes you only want the fields instead of an entire form component. When you use the fields this way, you design the component following Livewire conventions.

Think of it as a tool to auto-generate html for the fields, nothing else.

TallFormComponent vs Headless vs TallFormFields

(Standard form type)

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

Markup for Headless and TallFormFields

Important! ::blade not ::make

See Field Declaration page about differences

  • All fields are blade components. There are aliases in the config file.

  • You cannot use fields that lack "headless" support, like the Repeater.

  • Check the "Headless" tab on each field page, you might need to add traits.

  • You will not be able to use field methods like rules() or default()

  • Above, Below, Before, After, Help slots are available.

  • Validation errors are automatically displayed

Styling

"Headless" is usually used to refer to something without styling. With Tall-forms this is true in the sense that you control the styling in the theme file.

But, you can override the fields default styling when you declare the field in a blade view, which is why we can call it "headless" :)

Last updated