karan / laform
Laravel 表单构建器
dev-master
2016-02-28 19:43 UTC
Requires
- php: >=5.5.0
- laravelcollective/html: 5.*
This package is not auto-updated.
Last update: 2024-09-14 18:36:48 UTC
README
Laravel 5 的表单构建器
安装
在您的 composer.json 中添加此包并更新 composer,这将下载该包。
"karan/laform": "dev-master"
然后向 config/app.php 中添加服务提供者
Karan\Laform\LaformServiceProvider::class,
和 Facade(也在 config/app.php 中)
'Laform' => Karan\Laform\Facade::class
基本用法
语法
{!! Laform::field('fildname','fildtype','attributes') !!}
示例
{!! Laform::open(array('url'=>'admin/formtest','class'=>'form-horizontal')) !!}
{!! Laform::field('name','text',['label'=>'Name']) !!}
{!! Laform::field('email','email',['label'=>'Email address']) !!}
{!! Laform::field('password','password',['label'=>'Password']) !!}
{!! Laform::field('password_confirmation','password',['label'=>'Confirm Password']) !!}
{!! Laform::field('role_id[]','select',
['label'=>'Select Roles',
'options'=>[1=>'Admin',2=>'Siteadmin'],
'attr'=>['multiple'=>'multiple']]) !!}
{!! Laform::field('test_textarea','textarea',['label'=>'Text Area','attr'=>['rows'=>'5','cols'=>'10']]) !!}
{!! Laform::field('test_chexbox','checkbox',['option'=>'1','label'=>'test Checkox']) !!}
{!! Laform::field('test_radio','radio',['option'=>'1','label'=>'test Checkox']) !!}
{!! Laform::field('test_chexboxs[]','checkboxs',['option'=>['1'=>'option 1','2'=>'option 2',
'3'=>'option 3'],'label'=>'test Checkox']) !!}
{!! Laform::close() !!}
可用常见属性数组
[
//field value (use to set field value) - string/array (depends upon field type)
'value' => '' // default is null
//field attributes - array
'attr' => [] // default is empty array
//lable text - string
'lable' => '' // no default value, if not set lavle will not be displayed
//lable attributes - array
'label_attr' => [] // default is empty array
//template name
'template' => '' // default is whatever set in config
//custom wrapper prefix - can contain html
'prefix' => '' // default is empty
//custom wrapper suffix - can contain html
'suffix' => '' // default is empty
//field wrapper prefix - can contain html
'field_prefix' => '' // default is empty
//field wrapper prefix - can contain html
'field_suffix' => '' // default is empty
//wrapper - true/false
'wrapper' => '' // default is true
//wrapper attributes - array
'wrapper_attr' => [] // default is empty array
//show error blocks or not - true/flase
'show_errors' => '' // default is true
//error attributes - array
'error_attr' => [] // default is empty array
//help block
'help_block' => [
'text' => '' // default is empty
'attr' => [] // default is empty array
]
]