Re: Addrule not working

From: Date: Thu, 27 May 2010 09:06:41 +0000
Subject: Re: Addrule not working
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30584@lists.php.net to get a copy of this message
Hi Zia, On 25.05.2010 18:23, zia mohaddes wrote:
This is the entire code: function birth_details() { // add date of birth $this->form->addElement('date', 'dob1', 'Date of Birth', $dateOptions); $this->form->addElement('date', 'dob2', 'Confirm Date of Birth', $dateOptions); // date of birth rules $this->form->addRule('dob1', 'Date of Birth is required', 'required'); $this->form->addRule(array('dob1', 'dob2'), 'Date of Birth fields must match', 'compare');
addRule() with built-in Rules generally won't work on 'date' elements since those are groups. You either need to use addGroupRule() or write your own custom rules to check those. In your example, you should use addGroupRule() for 'required' and write a custom rule for 'compare' that will handle arrays properly.

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