cvs: pear /HTML_QuickForm/QuickForm/Renderer Savant.php

From: Date: Thu, 21 Jul 2005 16:50:50 +0000
Subject: cvs: pear /HTML_QuickForm/QuickForm/Renderer Savant.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-33200@lists.php.net to get a copy of this message
mansion Thu Jul 21 12:50:50 2005 EDT Modified files: /pear/HTML_QuickForm/QuickForm/Renderer Savant.php Log: Added hasRequired in Savant renderer. http://cvs.php.net/diff.php/pear/HTML_QuickForm/QuickForm/Renderer/Savant.php?r1=1.1&r2=1.2&ty=u Index: pear/HTML_QuickForm/QuickForm/Renderer/Savant.php diff -u pear/HTML_QuickForm/QuickForm/Renderer/Savant.php:1.1 pear/HTML_QuickForm/QuickForm/Renderer/Savant.php:1.2 --- pear/HTML_QuickForm/QuickForm/Renderer/Savant.php:1.1 Tue Feb 1 13:33:48 2005 +++ pear/HTML_QuickForm/QuickForm/Renderer/Savant.php Thu Jul 21 12:50:45 2005 @@ -16,7 +16,7 @@ // | Author: Bertrand Mansion <bmansion@mamasam.com> | // +----------------------------------------------------------------------+ // -// $Id: Savant.php,v 1.1 2005/02/01 18:33:48 mansion Exp $ +// $Id: Savant.php,v 1.2 2005/07/21 16:50:45 mansion Exp $ require_once 'HTML/QuickForm/Renderer/Array.php'; @@ -30,6 +30,7 @@ * 'javascript' => 'javascript for client-side validation', * 'attributes' => 'attributes for <form> tag', * 'requirednote => 'note about the required elements', + * 'hasrequired => 'whether the form contains any required fields', * // if we set the option to collect hidden elements * 'hidden' => 'collected html of all hidden elements', * // if there were some validation errors: @@ -110,18 +111,18 @@ * Constructor * * @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" * @access public */ - function HTML_QuickForm_Renderer_Savant($collectHidden = false, $staticLabels = false) + function HTML_QuickForm_Renderer_Savant($collectHidden = false) { - parent::HTML_QuickForm_Renderer_Array($collectHidden, $staticLabels); + parent::HTML_QuickForm_Renderer_Array($collectHidden); } // end constructor function startForm(&$form) { - parent::startForm(&$form); + parent::startForm($form); + $this->_ary['hasrequired'] = false; $this->_currentSection = 0; $this->_sectionCount = 1; } // end func startForm @@ -141,6 +142,10 @@ { $this->_groupElementIdx = 0; $this->_groupElementCount = count($group->getElements()); + if ($required) { + $this->_ary['hasrequired'] = true; + } + $this->_currentGroup = $this->_elementToArray($group, $required, $error); if (!empty($error)) { $this->_ary['errors'][$this->_currentGroup['name']] = $error; @@ -175,9 +180,14 @@ 'required' => $required, 'error' => $error ); + + if ($required) { + $this->_ary['hasrequired'] = true; + } + // render label(s) $labels = $element->getLabel(); - if (is_array($labels) && $this->_staticLabels) { + if (is_array($labels)) { foreach($labels as $key => $label) { $key = is_int($key)? $key + 1: $key; if (1 === $key) {

« previous php.pear.cvs (#33200) next »