A basic framework agnostic form building using materialize css framework package with a few extra niceties like remembering old input and retrieving error messages. Built on AdamWathan/BootForms
bcdbuddy/material-form
A basic framework agnostic form building using materialize css framework package with a few extra niceties like remembering old input and retrieving error messages. Built on AdamWathan/BootForms
You can install this package via Composer by running this command in your terminal in the root of your project:, (*2)
composer require bcdbuddy/material-form
Laravel
This package works great as a replacement Form Builder that was removed in Laravel 5. The API is different but all of the features are there., (*3)
If you are using Laravel 4 or 5, you can register the FormServiceProvider to automatically gain access to the Old Input and Error Message functionality., (*4)
To do so, just update the providers array in your config/app.php:, (*5)
Usage outside of Laravel is a little trickier since there's a bit of a dependency stack you need to build up, but it's not too tricky., (*8)
$formBuilder = new bcdbuddy\MaterialForm\FormBuilder;
$formBuilder->setOldInputProvider($myOldInputProvider);
$formBuilder->setErrorStore($myErrorStore);
$formBuilder->setToken($myCsrfToken);
$basicMaterialFormsBuilder = new bcdbuddy\MaterialForms\BasicFormBuilder($formBuilder);
$horizontalMaterialFormsBuilder = new bcdbuddy\MaterialForms\HorizontalFormBuilder($formBuilder);
$bootForm = new bcdbuddy\MaterialForms\MaterialForm($basicMaterialFormsBuilder, $horizontalMaterialFormsBuilder);
Note: You must provide your own implementations of bcdbuddy\Form\OldInputInterface and bcdbuddy\Form\ErrorStoreInterface when not using the implementations meant for Laravel., (*9)
Basic Usage
MaterialForms lets you create a label and form control and wrap it all in a form group in one call., (*10)
Note: Don't forget to open() forms before trying to create fields!, (*11)
Customizing Elements
If you need to customize your form elements in any way (such as adding a default value or placeholder to a text element), simply chain the calls you need to make and they will fall through to the underlying form element., (*12)
Attributes can be added either via the attribute method, or by simply using the attribute name as the method name., (*13)
Another nice thing about MaterialForms is that it will automatically add error states and error messages to your controls if it sees an error for that control in the error store., (*17)
Essentially, this takes code that would normally look like this:, (*18)
A basic framework agnostic form building using materialize css framework package with a few extra niceties like remembering old input and retrieving error messages. Built on AdamWathan/BootForms