Source for file Array.php
Documentation is available at Array.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Alexey Borzov <borz_off@cs.msu.su> |
// | Adam Daniel <adaniel1@eesus.jnj.com> |
// | Bertrand Mansion <bmansion@mamasam.com> |
// | Thomas Schulz <ths@4bconsult.de> |
// +----------------------------------------------------------------------+
// $Id: Array.php 6184 2005-09-07 10:08:17Z bmol $
require_once 'HTML/QuickForm/Renderer.php';
* A concrete renderer for HTML_QuickForm, makes an array of form contents
* Based on old toArray() code.
* The form array structure is the following:
* 'frozen' => 'whether the form is frozen',
* 'javascript' => 'javascript for client-side validation',
* 'attributes' => 'attributes for <form> tag',
* 'requirednote => 'note about the required elements',
* // if we set the option to collect hidden elements
* 'hidden' => 'collected html of all hidden elements',
* // if there were some validation errors:
* '1st element name' => 'Error for the 1st element',
* 'nth element name' => 'Error for the nth element'
* // if there are no headers in the form:
* // if there are headers in the form:
* 'header' => 'Header text for the first header',
* 'name' => 'Header name for the first header',
* 'header' => 'Header text for the Mth header',
* 'name' => 'Header name for the Mth header',
* where element_i is an array of the form:
* 'name' => 'element name',
* 'value' => 'element value',
* 'type' => 'type of the element',
* 'frozen' => 'whether element is frozen',
* 'label' => 'label for the element',
* 'required' => 'whether element is required',
* 'error' => 'error associated with the element',
* 'style' => 'some information about element style (e.g. for Smarty)',
* // if element is not a group
* 'html' => 'HTML for the element'
* // if element is a group
* 'separator' => 'separator for group elements',
* An array being generated
* Number of sections in the form (i.e. number of headers in it)
* Array representing current group
* Additional style information for different elements
* true: collect all hidden elements into string; false: process them as usual form elements
* true: render an array of labels to many labels, $key 0 named 'label', the rest "label_$key"
* false: leave labels as defined
* @param bool true: collect all hidden elements into string; false: process them as usual form elements
* @param bool true: render an array of labels to many labels, $key 0 to 'label' and the oterh to "label_$key"
$this->_staticLabels = $staticLabels;
* Returns the resultant array
'frozen' => $form->isFrozen(),
'javascript' => $form->getValidationScript(),
'attributes' => $form->getAttributes(true),
'requirednote' => $form->getRequiredNote(),
$this->_ary['hidden'] = '';
'header' => $header->toHtml(),
'name' => $header->getName()
} // end func renderHeader
$this->_ary['errors'][$elAry['name']] = $error;
} // end func renderElement
$this->_ary['hidden'] .= $element->toHtml() . "\n";
} // end func renderHidden
} // end func finishGroup
* Creates an array representing an element
* @param object An HTML_QuickForm_element object
* @param bool Whether an element is required
* @param string Error associated with the element
'name' => $element->getName(),
'value' => $element->getValue(),
'type' => $element->getType(),
'frozen' => $element->isFrozen(),
$labels = $element->getLabel();
if (is_array($labels) && $this->_staticLabels) {
foreach($labels as $key => $label) {
$key = is_int($key)? $key + 1: $key;
$ret['label_' . $key] = $label;
// set the style for the element
if ('group' == $ret['type']) {
$ret['separator'] = $element->_separator;
$ret['elements'] = array();
$ret['html'] = $element->toHtml();
* Stores an array representation of an element in the form array
* @param array Array representation of an element
// where should we put this element...
$this->_ary['elements'][] = $elAry;
* Sets a style to use for element rendering
* @param mixed element name or array ('element name' => 'style name')
* @param string style name if $elementName is not an array
|