Quickform 3: Array-Renderer

From: Date: Tue, 15 Apr 2003 20:56:31 +0000
Subject: Quickform 3: Array-Renderer
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15189@lists.php.net to get a copy of this message
Hi, today I had the time to test the new array renderer in the upcoming Quickform 3.0. It works fine in combination with the smarty-template I use to render my forms. I missed two things: an flag to detect if the complete form is frozen (useful to change the layout in this case) and the separator for grouped elements. These could be implemented by adding a public method I called isAllFrozen() in QuickForm.php... =================================================================== RCS file: /repository/pear/HTML_QuickForm/QuickForm.php,v retrieving revision 1.85 diff -r1.85 QuickForm.php 1115a1116,1131 > // {{{ isAllFrozen() > > /** > * Returns whether or not the complete form is frozen > * > * @since 3.0 > * @access public > * @return boolean > * @throws > */ > function isAllFrozen() > { > return $this->_freezeAll; > } // end func isAllFrozen > > // }}} ...adding a public method I called getGroupSeparator() in group.php... =================================================================== RCS file: /repository/pear/HTML_QuickForm/QuickForm/group.php,v retrieving revision 1.19 diff -r1.19 group.php 259a260,275 > // {{{ getGroupSeparator() > > /** > * Returns the separator for the group elements > * > * @since 3.0 > * @access public > * @return string > * @throws > */ > function getGroupSeparator() > { > return $this->_separator; > } // end func getGroupSeparator > > // }}} ...and use this new methods within the renderer Array.php: Index: Array.php =================================================================== RCS file: /repository/pear/HTML_QuickForm/QuickForm/Renderer/Array.php,v retrieving revision 1.3 diff -u -r1.3 Array.php --- Array.php 30 Mar 2003 17:09:37 -0000 1.3 +++ Array.php 15 Apr 2003 20:18:30 -0000 @@ -29,6 +29,7 @@ * * The form array structure is the following: * array( + * 'frozen' => 'whether the complete form is frozen', * 'validationScript' => 'javascript for client-side validation', * 'attributes' => 'attributes for <form> tag', * 'requiredNote => 'note about the required elements', @@ -77,6 +78,7 @@ * // if element is not a group * 'html' => 'HTML for the element' * // if element is a group + * 'separator' => 'separator for grouped elements' * 'elements' => array( * element_1, * ... @@ -138,6 +140,7 @@ function startForm(&$form) { $this->_ary = array( + 'frozen' => $form->isAllFrozen(), 'validationScript' => $form->getValidationScript(), 'attributes' => $form->getAttributesString(), 'requiredNote' => $form->getRequiredNote() @@ -206,6 +209,7 @@ 'required' => $required ); if ('group' == $ret['type']) { + $ret['separator'] = $element->getGroupSeparator(); $ret['elements'] = array(); } else { $ret['html'] = $element->toHtml(); I hope this is ok and sombody have time to implement this in one of the next releases. FYI: the array renderer works great for a "dynamic" smarty template (like ITDynamic.php for ITX/Sigma). I can provide an sample template for the docs. For an "static" smarty template (like ITStatic.php) we need an more simple array with element names as key. I will try to write this "ArrayStatic" renderer by reusing the toArray() method from Quickform 2.10... Thomas. -- http://4bconsult.de

« previous php.pear.dev (#15189) next »