RE: [PEAR] [QF] Changing the default javascript script
| From: | Mark Steudel | Date: | Tue, 10 Jan 2006 19:52:38 +0000 |
| Subject: | RE: [PEAR] [QF] Changing the default javascript script | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22492@lists.php.net to get a copy of this message | ||
Wow easy! Thanks
-----Original Message-----
From: Justin Patrin [mailto:papercrane@gmail.com]
Sent: Tuesday, January 10, 2006 11:00 AM
To: Mark Steudel
Cc: pear-general@lists.php.net
Subject: Re: [PEAR] [QF] Changing the default javascript script
On 1/10/06, Mark Steudel <mark@netriver.net> wrote:
> Im trying to modify the main validation javascript:
>
> return
> "\n<script type=\"text/javascript\">\n" .
> "//<![CDATA[\n" .
> "function validate_" . $this->_attributes['id'] .
> "(frm,
> verbose) {\n" .
> " var verbose = (!verbose) ? 1 : 0;\n" .
> " var value = '';\n" .
> " var errFlag = new Array();\n" .
> " var _qfGroups = {};\n" .
> " _qfMsg = '';\n\n" .
> join("\n", $test) .
> "\n if (_qfMsg != '' && verbose) {\n" .
> " _qfMsg = '" . strtr($this->_jsPrefix, $js_escape) .
"'
> + _qfMsg;\n" .
> " _qfMsg = _qfMsg + '\\n" . strtr($this->_jsPostfix,
> $js_escape) . "';\n" .
> " alert(_qfMsg);\n" .
> " return false;\n" .
> " }\n" .
> " return true;\n" .
> "}\n" .
> "//]]>\n" .
> "</script>";
> }
>
> Basically all it's doing is supressing the alerts if I want. I want to
> be able to run another script if the whole form passes validation:
>
> function new_script()
> {
> var verbose = 0;
> if ( validate_formname( formid, verbose ) )
> {
> do something here;
> }
> }
>
> I copied the whole getValidationScript() script out of the QuickForm
> class and thought perhaps I could extend the QuickForm class and some
> how tell my form to use this function instead of it's default
> function. So now I'm not really sure where to go from here.
>
Make a class which extends HTML_QuickForm, then use it to create your form.
It's that simple.
class MyForm extends HTML_QuickForm {
function getValidationScript() {
//...
}
}
$form = new MyForm();
--
Justin Patrin
--
PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php