Perforce Chronicle 2012.2/486814
API Documentation
|
Extends Zend_Form_Element_MultiCheckbox to support nesting items in UL's. More...
Public Member Functions | |
isValid ($value, $context=null) | |
Extends parent to ensure the 'InArray' validator gets a recursively flattened list of valid inputs. | |
Public Attributes | |
$helper = 'formNestedCheckbox' |
Extends Zend_Form_Element_MultiCheckbox to support nesting items in UL's.
This class simply sets the view helper which does all the actual work.
P4Cms_Form_Element_NestedCheckbox::isValid | ( | $ | value, |
$ | context = null |
||
) |
Extends parent to ensure the 'InArray' validator gets a recursively flattened list of valid inputs.
string | $value | name of checkbox to validate |
mixed | $context | optional context |
{ if ($this->registerInArrayValidator()) { if (!$this->getValidator('InArray')) { $options = array(); // create a recursive function we will use to flatten // the multi-dimensional array of options $flatten = function($array, &$flat) use (&$flatten) { foreach ($array as $optValue => $optLabel) { if (is_array($optLabel)) { $flatten($optLabel, $flat); continue; } $flat[] = $optValue; } }; // populate options with the flattened version of multi-option values $flatten($this->getMultiOptions(), $options); $this->addValidator( 'InArray', true, array($options) ); } } return parent::isValid($value, $context); }
P4Cms_Form_Element_NestedCheckbox::$helper = 'formNestedCheckbox' |