PHP code example of laravolt / semantic-form

1. Go to this page and download the library: Download laravolt/semantic-form 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/ */

    

laravolt / semantic-form example snippets


protected $routeMiddleware = [
    'selectdate' => \Laravolt\SemanticForm\Middleware\SelectDateMiddleware::class,
    'selectdatetime' => \Laravolt\SemanticForm\Middleware\SelectDateTimeMiddleware::class
];

Route::post('myForm', ['middleware' => ['web', 'selectdate:myDate'], function (\Illuminate\Http\Request $request) {
	dd($request->input('myDate')); // Will output 2016-5-4
}]);
 
// This is OK in version 1, but will produce error in version 2
{!! Form::bind($model) !!}

Form::macro('trix', function ($id, $name, $value = null) {
    return sprintf(
        "%s %s", 
        Form::hidden($name, $defaultValue)->id($id), 
        "<trix-editor input='{$id}'></trix-editor>"
    );
});

Form::trix('contentId', 'content', '<b>some content</b>');
 php
Form::open('search'); // action="search" method=POST
Form::get('search'); // action="search" method=GET
Form::post('search'); // action="search" method=POST
Form::put('search'); // action="search" method=POST _method=PUT
Form::patch('search'); // action="search" method=POST _method=PATCH
Form::delete('search'); // action="search" method=POST _method=DELETE
 php
Form::post('search')->withoutToken();
 php
Form::text($name, $value)->label('Username');
 php
Form::number($name, $integerValue)->label('Total');
 php
Form::rupiah($name, $defaultValue = null)->label('Price');
 php
Form::date($name, $value)->label('Birthday');
 php
Form::time($name, $value)->label('Start Time');
 php
Form::password($name)->label('Password');
 php
Form::email($name, $value)->label('Email Address');
 php
Form::textarea($name, $value)->label('Note');
 php
Form::select($name, $options)->label('Choose Country');
Form::select($name, $options, $selected)->label('Choose Country');
Form::select($name, $options)->placeholder('--Select--');
Form::select($name, $options)->appendOption($key, $label);
Form::select($name, $options)->prependOption($key, $label);
 php
Form::selectRange($name, $begin, $end)->label('Number of child');
 php
Form::selectMonth($name, $format = '%B')->label('Month');
 php
$checked = true;
Form::radio($name, $value, $checked)->label('Item Label');
 php
$values = ['apple' => 'Apple', 'banana' => 'Banana'];
$checkedValue = 'banana';
Form::radioGroup($name, $values, $checkedValue)->label('Select Fruit');
 php
Form::checkbox($name, $value, $checked)->label('Remember Me');
 php
$values = ['apple' => 'Apple', 'banana' => 'Banana'];
$checkedValue = 'banana';
Form::checkboxGroup($name, $values, $checkedValue)->label('Select Fruit');
 php
Form::file($name);
 php
Form::input($name, $defaultvalue);
Form::input($name, $defaultvalue)->appendIcon('search');
Form::input($name, $defaultvalue)->prependIcon('users');
Form::input($name, $defaultvalue)->appendLabel($label);
Form::input($name, $defaultvalue)->prependLabel($label);
Form::input($name, $defaultvalue)->type("password");
 php
Form::timepicker($name, $value);
 php
Form::hidden($name, $value);
 php
Form::button($value);
 php
Form::submit($value);
 php
{!! Form::bind($model) !!}
 php
Form::text($name, $value)->label('Username')->id('username')->addClass('foo');
Form::text($name, $value)->label('Username')->data('url', 'http://id-laravel.com');
Form::password($name, $value)->label('Password')->hint('Minimum 6 characters');
Form::password($name, $value)->label('Password')->hint('Minimum 6 characters', 'my-custom-css-class');