New validation rule: multiple

Published on and tagged with cakephp  validation

With changeset 7353 a new validation rule (resp. its implementation) has been added to the core validation rules: multiple.

It allows you to validate the data from SELECT elements. With the in parameter you can define the valid choices:

public $validate = array('name' => array('rule' => array('multiple', array('in' => range(0, 10)))));

And with using the min and max parameters you can specify the minimal resp. maximal number of non-zero choices the user has to select:

public $validate = array('name' => array('rule' => array('multiple', array('min' => 1, 'max' => 2))));

Happy baking :)

2 comments baked

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License