ifnot/validation-parser
最新稳定版本:0.4.2.1
Composer 安装命令:
composer require ifnot/validation-parser
包简介
README 文档
README
Simple Laravel validation rule parser for : auto-generate forms, auto-generate documentations etc ... from a simple Laravel Validation array.
Compatible with Laravel 4 and Laravel 5
Installation
composer require "ifnot/validation-parser"
Custom usage
In this example we will call the RuleSet parser with a custom view for rendering an automatic Form.
In the Controller Action / Route, we define witch view using for each field :
Ifnot\ValidationParser\RuleSet::$view = 'my.form.field'; return View::make('my.form.show');
In /view/my/form/show.blade.php we loop on each RuleSets and bind the property to the RuleSet view.
@foreach([ "email":"required|email", "civility":"required|in:M,F", "comment":"string" ] as $property => $rules) {{ \Ifnot\ValidationParser\RuleSet::parse($rules)->bind('property' => $property)->toString() }} @endforeach
In the RuleSet view /views/my/form/field.blade.php (specified before) :
<label>{{ $property }}</label> @if($ruleSet->isBoolean()) {{-- Here insert a input type radio --}} @elseif($ruleSet->isIn()) {{-- Here, you can insert a select with $ruleSet['in']->params witch contains an array of allowed values --}} @elseif($field->isExists()) {{-- Here a ajax loaded json from your table $ruleSet['in']->params[0] and the column $ruleSet['in']->params[1] --}} @endif
统计信息
- 总下载量: 297
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-04-23