Livewire Form Object

Build Form Objects that centralize form data, validation, and state management. Handles field definitions, validation rules, error handling, and data persistence separate from UI components. Activates when creating structured form data containers, implementing validation logic, or managing form state and submission.

naykel76 0b28c51 1.0 KB Updated

File contents

When to use me

  • When form logic needs to be reused across multiple components
  • When forms are large and need better organization
  • When the same form is used in different contexts (create vs edit)

Initial Setup

php artisan livewire:form ModelFormObject
namespace App\Livewire\Forms;

use App\Models\Model;
use Livewire\Attributes\Validate;
use Livewire\Form;
use Naykel\Gotime\Traits\Crudable;
use Naykel\Gotime\Traits\Formable;

class ModelFormObject extends Form
{
    use Crudable, Formable;

    public function init(Model $model): void
    {
        $this->editing = $model;
        $this->setFormProperties($this->editing);
    }
}

naykel76/gotime_site/tree/main/.ai/skills/livewire-form-object commit 0b28c51dc5

Frequently asked questions

npx skillmds@latest add naykel76/livewire-form-object