intentor/laravel-form
Composer 安装命令:
composer require intentor/laravel-form
包简介
Form helpers for Laravel 5.
关键字:
README 文档
README
Form helpers for Laravel 5
Currently the project is DISCONTINUED. However, feel free to fork it and continue its development!
Contents
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:
{
"require": {
"intentor/laravel-form": "~1.0"
}
}
Run composer update to add the package to your Laravel app.
At config/app.php, add the Service Provider and the Facade:
'providers' => [ 'Intentor\LaravelForm\ServiceProvider', ] //... 'aliases' => [ 'Form' => 'Intentor\LaravelForm\Facade' ]
Laravel 5.1+
At composer.json of your Laravel installation, add the following require line:
{
"require": {
"intentor/laravel-form": "~2.0"
}
}
Run composer update to add the package to your Laravel app.
At config/app.php, add the Service Provider and the Facade:
'providers' => [ Intentor\LaravelForm\ServiceProvider::class, ] //... 'aliases' => [ 'Form' => Intentor\LaravelForm\Facade::class, ]
Quick start
To create a form, you can user either Blade helpers or the Form Facade.
Using Blade helpers:
@form_open(action('SomeController@action')) @form_close
Using Facades:
{!! Form::open(action('SomeController@action')) !!}
{!! Form::close() !!}
Any controls you want to create must be placed between the opening and closing of the form.
Using Blade helpers:
@form_open(action('SomeController@action')) @form_text('name', 'Name') @form_buttons('Send', 'Reset') @form_close
Using Facades:
{!! Form::open(action('SomeController@action')) !!}
{!! Form::text('name', 'Name') !!}
{!! Form::buttons('Send', 'Reset') !!}
{!! Form::close() !!}
Helpers
open
Opens a form. See Themes for more details on form themes.
Blade helper
@form_open($url, $method = 'POST', $theme = null, $includeCsrfToken = true, $attributes = [])
Facade
{!! Form::open($url, $method = 'POST', $theme = null, $includeCsrfToken = true, $attributes = []) !!}
Parameters
- string
$urlAction URL. - string
$methodForm method. - bool
$themeControls' theme. It's a subfolder on the partials.form folder. - bool
$includeCsrfTokenIndicates whether the CSRF token should be included. - array
$attributesForm attributes.
model
Opens a form for a model. See Themes for more details on form themes.
Blade helper
@form_
Facade
{!! Form::model($model, $url, $method = 'POST', $theme = null, $includeCsrfToken = true, $attributes = []) !!}
Parameters
- object
$modelModel object. - string
$urlAction URL. - string
$methodForm method. - bool
$themeControls' theme. It's a subfolder on the partials.form folder. - bool
$includeCsrfTokenIndicates whether the CSRF token should be included. - array
$attributesForm attributes.
close
Closes a from.
Blade helper
@form_close
Facade
{!! Form::close() !!}
Parameters
None.
label
Creates a label.
Blade helper
@form_label($text, $field = null, $attributes = [])
Facade
{!! Form::label($text, $field = null, $attributes = []) !!}
Parameters
- string
$textLabel text. - string
$fieldRelated field name. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
readonly
Creates a readonly control.
Blade helper
@form_readonly($label, $text, $attributes = [])
Facade
{!! Form::readonly($label, $text, $attributes = []) !!}
Parameters
- string
$labelLabel text. - string
$textField text. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
hidden
Creates a hidden field.
Blade helper
@form_hidden($name, $value = null, $attributes = [])
Facade
{!! Form::hidden($name, $value = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$valueField value. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
text
Creates a text field.
Blade helper
@form_text($name, $label = null, $attributes = [])
Facade
{!! Form::text($name, $label = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
textarea
Creates a textarea field.
Blade helper
@form_textarea($name, $label = null, $attributes = [])
Facade
{!! Form::textarea($name, $label = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
Creates an e-mail field.
Blade helper
@form_email($name, $label = null, $attributes = [])
Facade
{!! Form::email($name, $label = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
url
Creates an URL field.
Blade helper
@form_url($name, $label = null, $attributes = [])
Facade
{!! Form::url($name, $label = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
number
Creates a number field.
Blade helper
@form_number($name, $label = null, $min = 0, $max = 9999, $step = 1, $attributes = [])
Facade
{!! Form::number($name, $label = null, $min = 0, $max = 9999, $step = 1, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - int
$minMinimum number. - int
$maxMaximum number. - int
$stepCombined with the min value, defines the acceptable numbers in the range. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
password
Creates a password field.
Blade helper
@form_password($name, $label = null, $attributes = [])
Facade
{!! Form::password($name, $label = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
checkbox
Creates a checkbox field.
Blade helper
@form_checkbox($name, $label = null, $value = 1, $attributes = [])
Facade
{!! Form::checkbox($name, $label = null, $value = 1, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - string
$valueField value. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
radio
Creates a radio field.
Blade helper
@form_radio($name, $label = null, $attributes = [])
Facade
{!! Form::radio($name, $label = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
checkboxGroup
Creates a checkbox group.
Blade helper
@form_checkbox_group($name, $label = null, $list = [], $selected = [], $attributes = [])
Facade
{!! Form::checkboxGroup($name, $label = null, $list = [], $selected = [], $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$listItem's list. Format: [ 'value' => '', 'text' => '' ]. Use modelToList to generate a list from models. - array
$selectedSelected values. Format: [ 'value', 'value', ... ]. Use modelToSelected to generate values from models. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
radioGroup
Creates a radio group.
Blade helper
@form_radio_group($name, $label = null, $list = [], $selected = null, $attributes = [])
Facade
{!! Form::radioGroup($name, $label = null, $list = [], $selected = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$listItem's list. Format: [ 'value' => '', 'text' => '' ]. Use modelToList to generate a list from models. - string
$selectedSelected value. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
dropdown
Creates a dropdown field.
Blade helper
@form_dropdown($name, $label = null, $list = [], $empty = null, $selected = null, $attributes = [])
Facade
{!! Form::dropdown($name, $label = null, $list = [], $empty = null, $selected = null, $attributes = []) !!}
Parameters
- string
$nameField name. - string
$labelField label. - array
$listItem's list. Format: [ 'value' => 'text', 'text' => '' ]. Use modelToList to generate a list from models. - string
$emptyEmpty value text. If no text is provided, there will not be an empty option. - string
$selectedSelected value. - array
$attributesElement attributes. Format: [ 'attribute' => 'value' ].
submit
Creates a submit button.
Blade helper
@form_submit($label)
Facade
{!! Form::submit($label) !!}
Parameters
- string
$labelControl label.
reset
Creates a reset button.
Blade helper
@form_reset($label)
Facade
{!! Form::reset($label) !!}
Parameters
- string
$labelControl label.
buttons
Creates form buttons (submit and reset).
Blade helper
@form_buttons($submitLabel, $resetLabel = null)
Facade
{!! Form::buttons($submitLabel, $resetLabel = null) !!}
Parameters
- string
$submitLabelSubmit button label. - string
$resetLabelReset 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
Form::modelToList($model, $valueField, $textField)
Parameters
- object
$modelModel to be converted. - string
$valueFieldField on data that is the value. - string
$textFieldField on data that is the text.
modelToSelected
Generates an array of selected values.
Facade
Form::modelToSelected($model, $valueField)
Parameters
- object
$modelModel to be converted. - string
$valueFieldField 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 support@intentor.com.br to discuss more obscure matters about the component.
License
Licensed under the The MIT License (MIT). Please see LICENSE for more information.
intentor/laravel-form 适用场景与选型建议
intentor/laravel-form 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 846 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 03 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「html」 「helper」 「laravel-5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 intentor/laravel-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 intentor/laravel-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 intentor/laravel-form 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Datetime helpers for timezone handling
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Library with classes to help you do batch.
This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
HTML and form generation
统计信息
- 总下载量: 846
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-12