Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_View_Helper_FormHidden Class Reference

Extended view helper for hidden form element to support rendering sequence of hidden elements in the case of element's value is an array. More...

List of all members.

Protected Member Functions

 _hidden ($name, $value=null, $attribs=null)
 Override parent to support for array of values.

Detailed Description

Extended view helper for hidden form element to support rendering sequence of hidden elements in the case of element's value is an array.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

P4Cms_View_Helper_FormHidden::_hidden ( name,
value = null,
attribs = null 
) [protected]

Override parent to support for array of values.

If $value is an array, then this method returns list of hidden elements where the name will have appended square brackets.

Parameters:
string$namethe element name
string | array$valueoptional - the element value or list of values
array$attribsoptional - attributes for the element
Returns:
string A hidden element or a sequence of hidden elements.
    {
        if (is_array($value)) {
            // for array values, remove id from attributes as there
            // would be multiple hidden elements with the same id
            unset($attribs['id']);

            // assemble list if hidden elements, one for each value
            $elementsList = array();
            foreach ($value as $singleValue) {
                $elementsList[] = parent::_hidden($name . '[]', $singleValue, $attribs);
            }

            return implode("\n", $elementsList);
        }

        return parent::_hidden($name, $value, $attribs);
    }

The documentation for this class was generated from the following file: