Re: PEAR QuickForm - some ideas
| From: | Martin Tsachev | Date: | Fri, 05 Jul 2002 11:15:37 +0000 |
| Subject: | Re: PEAR QuickForm - some ideas | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-1812@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
Hello Bertrand, this is it, you still need the form name for the js validation function though. I don't think that generating js functions with the same name is a nice idea if you have more than one form on the page. ****** QuickForm-2.3.phpI don't know but what's this obsession to name forms, things are really a lot easier and portable when you use the this keyword.I agree, could you submit a patch if you have time. (personally, I can't right now I am too busy).
821: $this->updateAttributes(array('onsubmit'=>'return validate_'.$this->_attributes['name'] . '();'));
****** QuickForm.php
821: $this->updateAttributes(array('onsubmit'=>'return validate_'.$this->_attributes['name'] . '(this);'));
******
****** QuickForm-2.3.php
1 114: $html .=
1 115: "$tabs\tfunction validate_" . $this->_attributes['name'] . "() {\n" .
1 116: "$tabs\t\terrFlag = new Array();\n" .
1 117: "$tabs\t\tmsg = '';\n" .
1 118: "$tabs\t\tfrm = document.forms['" . $this->_attributes['name'] . "'];\n";
****** QuickForm.php
1 114: $html .=
1 115: "$tabs\tfunction validate_" . $this->_attributes['name'] . "(frm) {\n" .
1 116: "$tabs\t\terrFlag = new Array();\n" .
1 117: "$tabs\t\tmsg = '';\n";
******
When I think now you don't benefit from this much, it is something that's good if you write the validation yourself not have it generated.
By the way do you think the group validation should be done this way or one needs to validate against each separate element?
I don't know why you decided to go with that validation style it's vice versa on most sites: JavaScript displays one error at a time and focuses the wrong field and server side shows all errors. One can argue that you should write your server side validation messages in such a way that people will know what to write from seeing one error per field only but I don't always do so.
--
Martin Tsachev
Web developer
http://members.evolt.org/shaggy/