cvs: pear /DB_Table/DB/Table QuickForm.php

From: Date: Thu, 13 Apr 2006 13:40:07 +0000
Subject: cvs: pear /DB_Table/DB/Table QuickForm.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39592@lists.php.net to get a copy of this message
wiesemann Thu Apr 13 13:40:07 2006 UTC Modified files: /pear/DB_Table/DB/Table QuickForm.php Log: - Fixed handling of QuickForm rules: If there was a server-side-only rule (like 'uploadedfile'), client-side validation was disabled for all rules. Now it is disabled only for server-side-only rules. - You can now use an extended HTML_QuickForm object by specifying the class name in $_DB_TABLE['qf_class_name']. http://cvs.php.net/viewcvs.cgi/pear/DB_Table/DB/Table/QuickForm.php?r1=1.33&r2=1.34&diff_format=u Index: pear/DB_Table/DB/Table/QuickForm.php diff -u pear/DB_Table/DB/Table/QuickForm.php:1.33 pear/DB_Table/DB/Table/QuickForm.php:1.34 --- pear/DB_Table/DB/Table/QuickForm.php:1.33 Wed Jan 18 20:53:13 2006 +++ pear/DB_Table/DB/Table/QuickForm.php Thu Apr 13 13:40:06 2006 @@ -12,7 +12,7 @@ * * @license http://www.gnu.org/copyleft/lesser.html LGPL * -* @version $Id: QuickForm.php,v 1.33 2006/01/18 20:53:13 wiesemann Exp $ +* @version $Id: QuickForm.php,v 1.34 2006/04/13 13:40:06 wiesemann Exp $ * */ @@ -33,6 +33,15 @@ ); } +/** +* If you want to use an extended HTML_QuickForm object, you can specify the +* class name in $_DB_TABLE['qf_class_name']. +* ATTENTION: You have to include the class file yourself, DB_Table does +* not take care of this! +*/ +if (!isset($GLOBALS['_DB_TABLE']['qf_class_name'])) { + $GLOBALS['_DB_TABLE']['qf_class_name'] = 'HTML_QuickForm'; +} /** * @@ -179,9 +188,9 @@ $trackSubmit = isset($args['trackSubmit']) ? $args['trackSubmit'] : false; - $form =& new HTML_QuickForm($formName, $method, $action, $target, - $attributes, $trackSubmit); - + $form =& new $GLOBALS['_DB_TABLE']['qf_class_name']($formName, $method, + $action, $target, $attributes, $trackSubmit); + return $form; } @@ -730,10 +739,12 @@ // loop through the rules and add them foreach ($col['qf_rules'] as $type => $opts) { - // override the onlyServer types so that we don't attempt - // client-side validation at all. + // some rules (e.g. rules for file elements) can only be + // checked on the server; therefore, don't use client-side + // validation for these rules + $ruleValidate = $validate; if (in_array($type, $onlyServer)) { - $validate = 'server'; + $ruleValidate = 'server'; } switch ($type) { @@ -789,12 +800,12 @@ case 'timestamp': // date "elements" are groups ==> use addGroupRule() $form->addGroupRule($elemname, $message, $type, $format, - null, $validate); + null, $ruleValidate); break; default: // use addRule() for all other elements $form->addRule($elemname, $message, $type, $format, - $validate); + $ruleValidate); break; }

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