_ary['sections'][$this->_sectionCount] = array(
'header' => $header->toHtml(),
'name' => $header->getName(),
'attributes' => $header->getAttributes(),
);
$this->_currentSection = $this->_sectionCount++;
} //
function _elementToArray(&$element, $required, $error)
{
$ret = (array)$element->getAttributes();
$ret['name'] = $element->getName();
if (!array_key_exists('id', $ret)) {
$id = $ret['name'];
if (substr($id, -2) == '[]') {
$id = substr($id, 0, strlen($id) - 2);
}
if (strstr($id, ']')) {
$id = trim($id, ']');
$id = str_replace('][', '-', $id);
$id = str_replace('[', '-', $id);
}
$ret['id'] = $id;
$element->setAttribute('id', $id);
}
$ret['value'] = $element->getValue();
$ret['type'] = $element->getType();
$ret['frozen'] = $element->isFrozen();
$ret['required'] = $required;
$ret['error'] = $error;
// render label(s)
$labels = $element->getLabel();
if (is_array($labels) && $this->_staticLabels) {
foreach($labels as $key => $label) {
$key = is_int($key)? $key + 1: $key;
if (1 === $key) {
$ret['label'] = $label;
} else {
$ret['label_' . $key] = $label;
}
}
} else {
$ret['label'] = $labels;
}
// set the style for the element
if (isset($this->_elementStyles[$ret['name']])) {
$ret['style'] = $this->_elementStyles[$ret['name']];
}
if ('group' == $ret['type']) {
$ret['separator'] = $element->_separator;
$ret['elements'] = array();
} else {
$ret['html'] = $element->toHtml();
}
return $ret;
}
}
?>