alexwenzel / bselements
为 Laravel 提供的 Bootstrap 快捷方式和元素
v1.2.0
2014-06-20 13:39 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2024-09-14 15:06:07 UTC
README
此包为 Laravel 4.2 提供表单元素,使用 Bootstrap 3 进行样式化。
- 在帮助文本区域显示第一个错误消息
- 使用错误类标记输入
- 自动重新填充表单元素
此包包含一个演示页面:使用 View::make('bselements::demopage')。
示例
{{ BsForm::useViewErrorBag($errors) }}
{{ BsForm::info('Info', 'Infotext', array()) }}
{{ BsForm::text('text', 'Text') }}
{{ BsForm::textAddon('left', 'Demo', 'textaddon1', 'Text-Addon') }}
{{ BsForm::textAddon('right', 'Demo', 'textaddon2', 'Text-Addon') }}
{{ BsForm::password('password', 'Password') }}
{{ BsForm::file('file', 'File') }}
{{ BsForm::select('select', 'Select', array(''=>'-- Choose --','s1'=>'Select 1','s2'=>'Select 2','s3'=>'Select 3')) }}
{{ BsForm::textarea('textarea', 'Textarea') }}
{{ BsForm::radioGroup('radiogroup', 'radioGroup', array('r1'=>'1','r2'=>'2','r3'=>'3')) }}
{{ BsForm::checkboxGroup('checkboxGroup', array('c1'=>'one','c2'=>'two','c3'=>'three')) }}
用法
首先在 app/conf/app.php 中注册服务提供者 Alexwenzel\Bselements\BselementsServiceProvider。
然后可以使用以下语法使用它
{{ BsForm::text('text', 'Text') }}
````
Bootstrap assets (CSS/JS) are not included! Include them yourself.
## Form elements
### Injecting validation messages
You can inject your validation messages within you template into the BsForm class.
````php
BsForm::useViewErrorBag($errors)
````
### Info
Generates a text input look-alike field, without any functionality.
````php
BsForm::info($label, $text, array $attributes = array())
````
### Text
Generates a text input element.
````php
BsForm::text($id, $label, array $attributes = array())
````
### Text Addon
Generates a text input element with addon.
````php
BsForm::textAddon($addonDirection, $addonContent, $id, $label, array $attributes = array())
````
* ``$addonDirection`` can be ``left`` or ``right``
* ``$addonContent`` can be any HTML/String
### File
Generates a file input element.
````php
BsForm::file($id, $label, array $attributes = array())
````
### Select
Generates a select element.
````php
BsForm::select($id, $label, array $elements, array $attributes = array())
````
### Password
Generates a password input element.
````php
BsForm::password($id, $label, array $attributes = array())
````
### Textarea
Generates a textarea element.
````php
BsForm::textarea($id, $label, array $attributes = array())
````
### Radio Group
Generates a group of radio elements.
````php
BsForm::radioGroup($id, $label, array $values)
````
### Checkbox Group
Generates a group of checkbox elements.
````php
BsForm::checkboxGroup($label, array $values)
````

