Home / News / Formello: Laravel Package for Creating Forms Quickly & Easily

Formello: Laravel Package for Creating Forms Quickly & Easily

šŸ¤– sarcastic summary with hashtags

Formello: The Laravel Package for Creating Forms, Simplified & Lightweight šŸš€

  • Simpler than complex form libraries šŸ… ļø
  • Lighter than full-featured admin panels like Nova or Filament šŸ… ļø

Formello makes the process of creating repetitive forms in Laravel a breeze. It offers a comprehensive solution with features that cater to developers’ every need, making it a must-have for Laravel users.

šŸ“ˆ Key Features

  • Easy-to-use form definition using Laravel classes

  • Automatic rendering directly to Blade

  • Supports various fields: text, textarea, select, select2, radio, checkbox, toggle, date, datetime, upload, hidden, and custom widgets

  • Automatic error handling, no need to create manually

  • <

    Formello: A Practical Solution for Creating Forms in Laravel šŸš€
    If you frequently code in Laravel, you’ve probably experienced the hassle of creating repetitive forms. From creating input fields, validation, error handling, to rendering in Blade. Well, now there’s Formello, a Laravel package specifically designed to simplify developers’ lives when creating forms.

    Formello offers the perfect compromise:

    • Simpler than complex form libraries.

    • Lighter than full-featured admin panels such as Nova or Filament.

    So, if you need to create forms quickly but still want them to be flexible and easy to manage, Formello could be your new best friend.

    ✨ Key Features of Formello

    • Easy-to-use form definition using Laravel classes.

    • Automatic rendering directly to Blade.

    • Supports various fields: text, textarea, select, select2, radio, checkbox, toggle, date, datetime, upload, hidden, and custom widgets.

    • Automatic error handling (no need to create manually).

    • Form validation is directly integrated.

    • Styling support: Bootstrap 5 (Tailwind CSS coming soon).

    • With this feature, you can focus on the logic of the application without having to copy and paste boilerplate forms.

    šŸ› ļø Formello Installation

    Installation is very easy. Install the package via composer:

    composer require metalogico/laravel-formello
    

    Publish your assets:

    php artisan vendor:publish --tag=formello-assets
    
    

    To automatically update assets every time composer updates, just add this to composer.json:

    "scripts": {
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=formello-assets --force"
        ]
    }
    

    šŸ˜Ž How to Use Formello in Laravel

    Alright, let’s get hands-on with Formello. Here’s how you can start using it in your Laravel project.

    1. Create a Form Class

    First, create a form class that extends Metalogico\Formello\Formello.
    Here’s a simple example for a ProductForm:

    <?php
    
    namespace App\Forms;
    
    use Metalogico\Formello\Formello;
    use Metalogico\Formello\Widgets\SelectWidget;
    
    class ProductForm extends Formello
    {
        protected function create(): array
        {
            return [
                'method' => 'POST',
                'action' => route('products.store'),
            ];
        }
    
        protected function edit(): array
        {
            return [
                'method' => 'POST',
                'action' => route('products.update', $this->model->id),
            ];
        }    
    
        protected function fields(): array
        {
            return [
                'name' => [
                    'label' => __('Product Name'),
                    'help' => 'Enter the name of the product',
                ],
                'description' => [
                    'label' => __('Description'),
                ],
                'category_id' => [
                    'label' => __('Category'),
                    'widget' => 'select',
                    'choices' => Category::pluck('name', 'id')->toArray(),
                ],
                'in_stock' => [
                  'label' => __('In Stock'),
                ],
            ];
        }
    }
    

    āš ļø Note: Make sure these fields are added to your model’s $fillable array, otherwise Formello won’t render them.

    class Product extends Model
    {
        protected $fillable = [
            'name',
            'category_id',
            'description',
            'in_stock',
        ];
    }
    

    šŸ‘‰ Read the full article at ramacan.dev

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *