laracore / formbuilder
Laravel 5.x FormBuilder for Blade Engine based on Bootstrap 3
Requires
- php: >= 5.5.9
- illuminate/support: 5.1.*
- laravelcollective/html: 5.1.*
This package is not auto-updated.
Last update: 2025-04-24 02:58:25 UTC
README
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);