Re: [Quickform] custom form rule function issue

From: Date: Tue, 01 Aug 2006 09:55:21 +0000
Subject: Re: [Quickform] custom form rule function issue
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24805@lists.php.net to get a copy of this message
Hi, Damien Cros wrote:
I've written a custom function to validate my form (using addFormRule). I don't know what to return when some of my elements have a name like tab[elem].
That depends on whether the elements are within a group or not. You should return an error with a group name ('tab' most likely) if they are and with a name 'tab[elem]' if they aren't. Also you should return true if validation succeeds, *not* an empty array.
For instance with the following generated html: <input size="30" maxlength="60" id="txt1" name="tab[txt1]" type="text" value="" /> and: function validate_form() { $errors = array(); if($values['tab']['txt1'] == "azerty") { $errors['tab']['txt1'] = "error text"; // doesn't work $errors['tab[txt1]'] = "error text"; // doesn't work } return $errors; } Any idea?


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