ifnot/validation-parser 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-04-23