Semantic Form
Semantic UI form builder, for Laravel.
Installation
Via Composer
$ composer require laravolt/semantic-form
Service Provider
Laravolt\SemanticForm\ServiceProvider::class,
Facade (Alias)
'SemanticForm' => Laravolt\SemanticForm\Facade::class,
API
Opening Form
SemanticForm::open()->get();
SemanticForm::open()->post();
SemanticForm::open()->put();
SemanticForm::open()->patch();
SemanticForm::open()->delete();
SemanticForm::open(); // default to method="GET"
SemanticForm::open()->action('search');
SemanticForm::open()->post()->action(route('comment.store'));
Input Text
SemanticForm::text($name, $value)->label('Username');
Password
SemanticForm::text($name, $value)->label('Password');
SemanticForm::email($name, $value)->label('Email Address');
Textarea
SemanticForm::textarea($name, $value)->label('Note');
Select Box (Dropdown)
SemanticForm::select($name, $options)->label('Choose Country');
SemanticForm::select($name, $options, $selected)->label('Choose Country');
SemanticForm::select($name, $options)->placeholder('--Select--');
SemanticForm::select($name, $options)->appendOption($key, $label);
SemanticForm::select($name, $options)->prependOption($key, $label);
Select Date
SemanticForm::selectDate($name, $startYear, $endYear)->label('Birth Date');
Select Date Time
SemanticForm::selectDateTime($name, $startYear, $endYear, $intervalInMinute)->label('Schedule');
Select Range
SemanticForm::selectRange($name, $begin, $end)->label('Number of child');
Select Month
SemanticForm::selectMonth($name, $format = '%B')->label('Month');
Radio
$checked = true;
SemanticForm::radio($name, $value, $checked)->label('Item Label');
Radio Group
$values = ['apple' => 'Apple', 'banana' => 'Banana'];
$checkedValue = 'banana';
SemanticForm::radioGroup($name, $values, $checkedValue)->label('Select Fruit');
Checkbox
SemanticForm::checkbox($name, $value, $checked)->label('Remember Me');
Checkbox Group
$values = ['apple' => 'Apple', 'banana' => 'Banana'];
$checkedValue = 'banana';
SemanticForm::checkboxGroup($name, $values, $checkedValue)->label('Select Fruit');
File
SemanticForm::file($name);
Image (Not Yet Implemented)
SemanticForm::image($name);
Datepicker (Not Yet Implemented)
SemanticForm::datepicker($name, $value, $format);
Redactor (Not Yet Implemented)
SemanticForm::redactor($name, $value)->label('Post Body');
Hidden
SemanticForm::hidden($name, $value);
Button
SemanticForm::button($value);
Submit
SemanticForm::submit($value);
Model Binding
SemanticForm::bind($model);
General Function
For every form element, you can call and chaining following methods:
- id($string)
- addClass($string)
- removeClass($string)
- attribute($name, $value)
- data($name, $value)
Example
SemanticForm::text($name, $value)->label('Username')->id('username')->addClass('foo');
SemanticForm::text($name, $value)->label('Username')->data('url', 'http://id-laravel.com');
Middleware
- \Laravolt\SemanticForm\Middleware\SelectDateMiddleware
- \Laravolt\SemanticForm\Middleware\SelectDateTimeMiddleware
Credits
SemanticForm built on top of awesome form builder by AdamWathan\Form.