PHP code example of djigir / laravel-form-builder
1. Go to this page and download the library: Download djigir/laravel-form-builder library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
djigir / laravel-form-builder example snippets
// config/app.php
'providers' => [
// ...
Djigir\LaravelFormBuilder\FormServiceProvider::class,
],
'aliases' => [
// ...
'Form' => Djigir\LaravelFormBuilder\Facades\Form::class,
],
// Basic form
{!! Form::open(['action' => 'UserController@store']) !!}
{!! Form::close() !!}
// Form with route
{!! Form::open(['route' => 'users.store']) !!}
{!! Form::close() !!}
// Form with route parameters
{!! Form::open(['route' => ['users.update', $user->id], 'method' => 'PUT']) !!}
{!! Form::close() !!}
// Form with model binding
{!! Form::model($user, ['route' => ['users.update', $user->id], 'method' => 'PUT']) !!}
{!! Form::close() !!}
// Text input
{!! Form::text('username') !!}
{!! Form::text('username', 'Default Value') !!}
{!! Form::text('username', null, ['class' => 'form-control']) !!}
// Email input
{!! Form::email('email') !!}
// Password input
{!! Form::password('password') !!}
// Number input
{!! Form::number('age') !!}
// Tel input
{!! Form::tel('phone') !!}
// Date inputs
{!! Form::date('birth_date') !!}
{!! Form::datetime('created_at') !!}
{!! Form::time('meeting_time') !!}
// Color picker
{!! Form::color('favorite_color') !!}
// Range slider
{!! Form::range('volume', 50) !!}
// File upload
{!! Form::file('avatar') !!}
// Hidden input
{!! Form::hidden('user_id', 1) !!}
{!! Form::textarea('description') !!}
{!! Form::textarea('description', 'Default content') !!}
{!! Form::textarea('description', null, ['rows' => 5, 'cols' => 40]) !!}
// Basic select
$options = ['1' => 'Option 1', '2' => 'Option 2'];
{!! Form::select('choice', $options) !!}
// Select with pre-selected value
{!! Form::select('choice', $options, '2') !!}
// Select with attributes
{!! Form::select('choice', $options, null, ['class' => 'form-control']) !!}
// Select range (useful for numbers)
{!! Form::selectRange('quantity', 1, 10) !!}
// Select year dropdown
{!! Form::selectYear('year') !!}
{!! Form::selectYear('year', 1990, 2030) !!}
// Select month dropdown
{!! Form::selectMonth('month') !!}
// Checkbox
{!! Form::checkbox('active', 1) !!}
{!! Form::checkbox('active', 1, true) !!} // checked
{!! Form::checkbox('active', 1, false, ['class' => 'form-check-input']) !!}
// Radio buttons
{!! Form::radio('gender', 'male') !!}
{!! Form::radio('gender', 'female', true) !!} // selected