Coder Social home page Coder Social logo

cakephp-parsley-helper's Introduction

CakePHP Parsley.js Form Helper

CakePHP Form Helper for Parsley.js automatic validation integration

This helper will automatically read validation rules from active form model and assign field attributes accordingly.

Compatible with Cake 2.4.7+

Feel free to make any code/docs contributions or post any issues.

Build Status

Basic usage

  1. Enable the helper plugin in your app/Config/bootstrap.php by doing CakePlugin::load('ParsleyHelper'); - or just CakePlugin::loadAll();.

  2. Load helper in your app/Controller/AppController.php. You can use the classname option if you want to keep your helper alias as "Form".

    // In AppController.php
    
    public $helpers = array('ParsleyHelper.ParsleyForm');
    // or
    public $helpers = array('Form' => array('className' => 'ParsleyHelper.ParsleyForm'));
  3. Enable Parsley rules integration in any form by setting parsley => true or data-parsley-validate => true in Form->create() options array.

    echo $this->Form->create('MyModel', array('parsley' => true));
  4. That's all! When you create an input field, parsley attributes will be set according to the defined validation rules.

Trait usage

If you are running PHP 5.4 or greater, and already using a custom or vendor form helper, you can make use of provided ParsleyFormTrait and retain both helper functionalities. You can do so by creating a custom helper in your app/View/Helper folder like this:

// In app/View/Helper

App::uses('ParsleyFormTrait', 'ParsleyHelper.View/Helper');

class MyFormHelper extends VendorFormHelper {
	use ParsleyFormTrait;
}

cakephp-parsley-helper's People

Contributors

codaxis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.