Re: QF 3.2 - regex throwing errors

From: Date: Wed, 05 Nov 2003 20:18:56 +0000
Subject: Re: QF 3.2 - regex throwing errors
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8788@lists.php.net to get a copy of this message
<mikeatwork@ukonline.co.uk> wrote : > > >> -----Original Message----- >> From: Bertrand Mansion [mailto:bmansion@mamasam.com] >> >> <mikeatwork@ukonline.co.uk> wrote : >> >>> Hi, >>> >>> Just upgraded to QF 3.2 and appear to be getting a regular >> expression >>> error now. >>> >>> I defined a rule to check if a postcode entered was valid: >>> >>> $this->addRule('postcodeGroup', >> $this->language['L_InvalidPostcode'], >>> 'regex', '/[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} >> {0,1}[0-9][A-Za-z]{2}/', >>> 'client'); >> >> Maybe because your postcodeGroup is a group ? >> Send the element declaration so we can check this. > > The declaration is as follows:- > > $postcode = array(); > $postcode[] = &HTML_QuickForm::createElement('text', 'postcode', > '', > array('size' => '25', 'maxlength' => '10', > 'tabindex' => 2)); > $postcode[] = &HTML_QuickForm::createElement('static', '', > '', > str_replace('#helptext#', $this->language['L_HelpPostcode'], > $helpButton)); > $this->addGroup($postcode, 'postcodeGroup', > $this->language['L_YourPostcode']); > > >>> When the form is submitted the validation appears to be executed on >>> the server side now (why?) and also kicks up the warning: >> >> Do you really wonder why we enforce server-side validation ? :) > > Heh. My query was because, the last time I checked before upgrading to QF > 3.2, javascript validation was being executed. Now its not. It's probably not executed because the generated javascript is wrong, look at the javascript source. Also, have a look at : http://pear.php.net/manual/en/package.html.html-quickform.intro-validation.p hp Specifically the part on group validation. It says: "To validate a group as a whole, just use HTML_QuickForm::addRule(). All your elements will then be validated one after the other using the same rule." Your group has a static element, which causes problem if you use addRule(). You should use addGroupRule() and specify the rule only for your first element. Look at the example 7 in docs/ too. This is not a bug, but a misuse. I am surprised though that it was working before... Probably because group validation was still incomplete. Bertrand Mansion Mamasam

« previous php.pear.general (#8788) next »