承接 artisaninweb/laravel-formvalidation-helper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

artisaninweb/laravel-formvalidation-helper

Composer 安装命令:

composer require artisaninweb/laravel-formvalidation-helper

包简介

A helper to easy validate laravel forms.

README 文档

README

A helper to easy validate laravel forms.

Installation

Add artisaninweb/laravel-formvalidation-helper as requirement to composer.json

{
    "require": {
        "artisaninweb/laravel-formvalidation-helper": "0.1.*"
    }
}

Replace 'Illuminate\Html\HtmlServiceProvider' with 'Artisaninweb\FormValidationHelper\ServiceProvider'

Replace in aliases 'Form' => 'Illuminate\Support\Facades\Form' with 'Form' => 'Artisaninweb\FormValidationHelper\Facades\Form'

Usage

The parameters to use:

required (bool): Make the field required.
rules (string): Specify the rules of the validation.
error-class (string): Add a custom class to the form field on error (optional, default: 'error').

Form::text('field-name','field-value',[required' => true, 'rules' => 'required|email', 'error-class' => 'form-error']);

To output the error you can place this in your view.
Default the error wil come from the validator, you can edit this in /app/lang/{lang}/validation.php.

// Replace the error with you own.
Form::error('field-name','<p>You can put a custom html error here.</p>');

// Only replace the html tags
Form::error('field-name','<p>:message</p>');

Example:

echo Form::open(['url' => '/login']);
echo Form::text('email', '', ['required' => true, 'rules' => 'required|email', 'error-class' => 'form-error']);
echo Form::error('email', '<p>This field is required.</p>');
echo Form::password('password', '', ['required' => true, 'rules' => 'required|min:8', 'error-class' => 'form-error']);
echo Form::error('password', '<p>This field is required.</p>');
echo Form::submit('Login');
echo Form::close();

After a form submit you can validate the last submitted form.

Form::validate(function($postData,$passes,$messages) {
    var_dump($postData);
    var_dump($passes);
    var_dump($messages);
});

TwigBridge

If you are using https://github.com/rcrowe/TwigBridge as TwigBirdge in Laravel (like i do).
You can replace 'TwigBridge\Extension\Laravel\Form' with 'Artisaninweb\FormValidationHelper\Extension\TwigBridgeForm'.
You will find this in app/config/packages/rcrowe/twigbridge/extensions.

统计信息

  • 总下载量: 48
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-08-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固