KHIT93 / FormBuilder by Kenneth_H

Laravel 5.x FormBuilder for Blade Engine based on Bootstrap 3
29
0
2
Package Data
Maintainer Username: Kenneth_H
Package Create Date: 2016-05-09
Package Last Update: 2016-05-24
Language: PHP
License: MIT
Last Refreshed: 2024-04-30 15:11:54
Package Statistics
Total Downloads: 29
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laracore FormBuilder

Laravel 5.1 FormBuilder for Blade Engine, based on Bootstrap 3 and used in Laracore CMS.

This FormBuilder allows for creation of HTML forms using objects and renders them using the Laravel Collective FormBuilder and the Bootstrap CSS Framework.

##Features

  • Object to HTML mapping based on the Bootstrap framework

  • Modifiable views for each form component

  • Support for Laravel Form Model Binding

  • Extensible API for an easy way to add new components

Installation

$> composer require "laracore/formbuilder:dev-master"

$> composer update

Next, add your new provider to the providers array of config/app.php:

Laracore\FormBuilder\FormBuilderServiceProvider::class,

Finally, add two class aliases to the aliases array of config/app.php:

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,

We use the Facades from Laravel Collective.

Usage

All Bootstrap recommendations for form and input elements are predefined in the provided classes and just have to be used or you can override them and provide your own.

Create a new form

$form = new FormBuilder();

Add a component

$form->addComponent(new TextField('name', 'Name'));

Render the form

$form->render();

Adding multiple components at once

$components = [
	new TextField('name', 'Name'),
	new PasswordField('password', 'Password'),
	new PasswordField('confirm_password' 'Confirm your password'),
	new SubmitButton('Register user')
];

$form->addComponent($components);

Create form using named constructor

$model = new App\User();
$form = FormBuilder::create('POST', ['class' => 'form-horizontal', 'role' => 'form'], $model);

$components = [
	new TextField('name', 'Name'),
	new PasswordField('password', 'Password'),
	new PasswordField('confirm_password' 'Confirm your password'),
	new SubmitButton('Register user')
];

$form->addComponent($components);

Create form and add components using named constructor

$model = new App\User();

$components = [
	new TextField('name', 'Name'),
	new PasswordField('password', 'Password'),
	new PasswordField('confirm_password' 'Confirm your password'),
	new SubmitButton('Register user')
];

$form = FormBuilder::create('POST', ['class' => 'form-horizontal', 'role' => 'form'], $model, $components);