Download the PHP package intentor/laravel-form without Composer
On this page you can find all versions of the php package intentor/laravel-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-form
Form helpers for Laravel 5
Currently the project is DISCONTINUED. However, feel free to fork it and continue its development!
Contents
- Introduction
- Installation
- Quick start
- Helpers
- open
- model
- close
- label
- readonly
- hidden
- text
- textarea
- url
- number
- password
- checkbox
- radio
- checkboxGroup
- radioGroup
- dropdown
- submit
- reset
- buttons
- Utilities
- modelToList
- modelToSelected
- Themes
- Changelog
- Support
- License
Introduction
Laravel Form provides a series of helpers for form creation in PHP pages and Blade templates.
Compatible with Laravel 5.
Installation
Laravel 5.0
At composer.json
of your Laravel installation, add the following require line:
Run composer update
to add the package to your Laravel app.
At config/app.php
, add the Service Provider and the Facade:
Laravel 5.1+
At composer.json
of your Laravel installation, add the following require line:
Run composer update
to add the package to your Laravel app.
At config/app.php
, add the Service Provider and the Facade:
Quick start
To create a form, you can user either Blade helpers or the Form
Facade.
Using Blade helpers:
Using Facades:
Any controls you want to create must be placed between the opening and closing of the form.
Using Blade helpers:
Using Facades:
Helpers
open
Opens a form. See Themes for more details on form themes.
Blade helper
Facade
Parameters
- string
$url
Action URL. - string
$method
Form method. - bool
$theme
Controls' theme. It's a subfolder on the partials.form folder. - bool
$includeCsrfToken
Indicates whether the CSRF token should be included. - array
$attributes
Form attributes.
model
Opens a form for a model. See Themes for more details on form themes.
Blade helper
Facade
Parameters
- object
$model
Model object. - string
$url
Action URL. - string
$method
Form method. - bool
$theme
Controls' theme. It's a subfolder on the partials.form folder. - bool
$includeCsrfToken
Indicates whether the CSRF token should be included. - array
$attributes
Form attributes.
close
Closes a from.
Blade helper
Facade
Parameters
None.
label
Creates a label.
Blade helper
Facade
Parameters
- string
$text
Label text. - string
$field
Related field name. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
readonly
Creates a readonly control.
Blade helper
Facade
Parameters
- string
$label
Label text. - string
$text
Field text. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
hidden
Creates a hidden field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$value
Field value. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
text
Creates a text field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
textarea
Creates a textarea field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
Creates an e-mail field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
url
Creates an URL field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
number
Creates a number field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - int
$min
Minimum number. - int
$max
Maximum number. - int
$step
Combined with the min value, defines the acceptable numbers in the range. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
password
Creates a password field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
checkbox
Creates a checkbox field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - string
$value
Field value. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
radio
Creates a radio field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
checkboxGroup
Creates a checkbox group.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$list
Item's list. Format: [ 'value' => '', 'text' => '' ]. Use modelToList to generate a list from models. - array
$selected
Selected values. Format: [ 'value', 'value', ... ]. Use modelToSelected to generate values from models. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
radioGroup
Creates a radio group.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$list
Item's list. Format: [ 'value' => '', 'text' => '' ]. Use modelToList to generate a list from models. - string
$selected
Selected value. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
dropdown
Creates a dropdown field.
Blade helper
Facade
Parameters
- string
$name
Field name. - string
$label
Field label. - array
$list
Item's list. Format: [ 'value' => 'text', 'text' => '' ]. Use modelToList to generate a list from models. - string
$empty
Empty value text. If no text is provided, there will not be an empty option. - string
$selected
Selected value. - array
$attributes
Element attributes. Format: [ 'attribute' => 'value' ].
submit
Creates a submit button.
Blade helper
Facade
Parameters
- string
$label
Control label.
reset
Creates a reset button.
Blade helper
Facade
Parameters
- string
$label
Control label.
buttons
Creates form buttons (submit and reset).
Blade helper
Facade
Parameters
- string
$submitLabel
Submit button label. - string
$resetLabel
Reset button label. If no label is given, the button is not created.
Utilities
modelToList
Generates an array compatible with lists (dropdowns, checkbox groups, etc.).
Facade
Parameters
- object
$model
Model to be converted. - string
$valueField
Field on data that is the value. - string
$textField
Field on data that is the text.
modelToSelected
Generates an array of selected values.
Facade
Parameters
- object
$model
Model to be converted. - string
$valueField
Field on data that is the value.
Themes
Themes are a way to customize the look of forms using partial views.
Available themes
There are three different themes available:
- default: a simple form theme without any third party dependencies.
- horizontal: default Bootstrap horizontal form (Requires Bootstrap 3).
- vertical: default Bootstrap vertical form (Requires Bootstrap 3).
All themes are subfolders at src/resources/views/partials/form
folder.
Creating a custom theme
To create a custom theme, copy a base theme from vendor/intentor/laravel-form/src/resources/views/partials/form
at your local Laravel installation to the resources/views/partials/form
of your app.
Each helper has its own Blade template file, which can then be customized.
Note: the name of the theme's folder is the name that must be used when setting the theme.
Changelog
Please see CHANGELOG.md.
Support
Found a bug? Please create an issue on the GitHub project page or send a pull request if you have a fix or extension.
You can also send me a message at [email protected] to discuss more obscure matters about the component.
License
Licensed under the The MIT License (MIT). Please see LICENSE for more information.