steelants/livewire-form

Simple Form class based on Laravel & Livewire

dev-main 2025-01-06 23:11 UTC

This package is auto-updated.

Last update: 2025-01-06 23:11:54 UTC


README

Basic Form Component For Creation/Update of model

<?php
namespace App\Livewire;

use App\Models\PersonChild;
use SteelAnts\LivewireForm\Livewire\FormComponent;
use SteelAnts\LivewireForm\Traits\HasModel;

class FormTest extends FormComponent
{
    use HasModel;

    public $model = PersonChild::class;
    public $model_id;

    //Oweride default labels generated from $fillables of model or define own if you are not using them HasModel Attribute
    function labels(){
        return [
            'name' => __('Jméno')
        ];
    }

    function onSuccess(){
        //DO SOMETHING ON SUCESS;
    }

    function onError(){
        //DO SOMETHING ON ERROR;
    }
}
@livewire('form-test', ['model_id' => 2])

Dev Enviroment

  1. Clone Repo to [LARVEL-ROOT]packages/
  2. Modify ;composer.json`
    "autoload": {
        "psr-4": {
            ...
            "SteelAnts\\LivewireForm\\": "packages/livewire-form/src/"
            ...
        }
    },
  1. Add (code below) to: [LARVEL-ROOT]packages/bootstrap/providers.php
SteelAnts\LivewireForm\LivewireFormServiceProvider::class,

Contributors

Other Packages

steelants/datatable

steelants/form

steelants/modal

steelants/boilerplate