Skip to content

Latest commit

 

History

History
58 lines (52 loc) · 1.4 KB

README.md

File metadata and controls

58 lines (52 loc) · 1.4 KB

HTML form helper for Laravel

Features

  • Simple form elements creation with laravel errors from validation
  • Fully customizable form elements with fluent interface

Installation

composer require kgrzelak/laravel-form

After installation, you can publish config file.

php artisan vendor:publish --provider="Kgrzelak\LaravelForm\LaravelFormServiceProvider"

Usage examples in blade

Form input

Form::input()
    ->name('input-name')
    ->type('text')
    ->value('input-value')
    ->placeholder('input-placeholder')
    ->setClass('form-control')
    ->addClass('mt-5')
    ->attribute('readonly', 'readonly')
    ->attribute('required', 'required');

Form textarea

Form::textarea()
    ->name('textarea-name')
    ->value('textarea-value')
    ->placeholder('textarea-placeholder')
    ->setClass('form-control')
    ->addClass('mt-5')
    ->attribute('readonly', 'readonly')
    ->attribute('required', 'required');

Form select

Form::select()
    ->name('select-name')
    ->setOptions([
        'option-value-1' => 'option-label-1',
        'option-value-2' => 'option-label-2',
        'option-value-3' => 'option-label-3',
    ])
    ->addOption('option-value-4', 'option-label-4')
    ->value('option-value-2')
    ->setClass('form-control')
    ->addClass('mt-5')
    ->attribute('readonly', 'readonly')
    ->attribute('required', 'required');