From: zia mohaddes on
Hello everyone,

I am currently using addrule in my quickform as follows to do the following:

$this->form->addRule('dob1', 'Date of Birth is required', 'required');
$this->form->addRule(array('dob1', 'dob2'), 'Date of Birth fields must
match', 'compare');

but unfortunately this doesn't work at all? Am i missing something??

Thank you kindly for your help in advance!

regards,

zia
From: Mark Steudel on
Those rules look correct, let's see the rest of your form.

MS

On Tue, May 25, 2010 at 9:23 AM, zia mohaddes <zia.simab(a)gmail.com> wrote:
> Hello everyone,
>
> I am currently using addrule in my quickform as follows to do the following:
>
> $this->form->addRule('dob1', 'Date of Birth is required', 'required');
> $this->form->addRule(array('dob1', 'dob2'), 'Date of Birth fields must
> match', 'compare');
>
> but unfortunately this doesn't work at all? Am i missing something??
>
> Thank you kindly for your help in advance!
>
> regards,
>
> zia
>



--

-----------------------------------------
Mark Steudel
P: 206.375.7244
msteudel(a)gmail.com

.. : Work : .
http://www.mindfulinteractive.com

.. : Play : .
http://www.steudel.org/blog
From: zia mohaddes on
Hi mark,

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');

//$form->addRule(array('cmpPasswd', 'cmpRepeat'), 'The passwords do not
match', 'compare', null, 'client');

// add gender
$genderOptions = array('', 'Male' => 'Male', 'Female' => 'Female',
'expected'=>'Expected', 'no_birth'=>'No Birth');
$this->form->addElement('select', 'gender', 'Gender', $genderOptions);
// add to form
// $this->tpl_data['elements_list'][]="gender";

// gender rules
$this->form->addRule('gender', 'Gender is required', 'required');

$this->form->addFormRule(array(&$this, '_validate'));

}

birth_details() is in fact the constructor!

Thank you kindly,

for your help!

regards,

zia

On Tue, May 25, 2010 at 9:28 AM, Mark Steudel <msteudel(a)gmail.com> wrote:

> Those rules look correct, let's see the rest of your form.
>
> MS
>
> On Tue, May 25, 2010 at 9:23 AM, zia mohaddes <zia.simab(a)gmail.com> wrote:
> > Hello everyone,
> >
> > I am currently using addrule in my quickform as follows to do the
> following:
> >
> > $this->form->addRule('dob1', 'Date of Birth is required', 'required');
> > $this->form->addRule(array('dob1', 'dob2'), 'Date of Birth fields must
> > match', 'compare');
> >
> > but unfortunately this doesn't work at all? Am i missing something??
> >
> > Thank you kindly for your help in advance!
> >
> > regards,
> >
> > zia
> >
>
>
>
> --
>
> -----------------------------------------
> Mark Steudel
> P: 206.375.7244
> msteudel(a)gmail.com
>
> . : Work : .
> http://www.mindfulinteractive.com
>
> . : Play : .
> http://www.steudel.org/blog
>
From: Mark Steudel on
Where are you validating the form?

On Tue, May 25, 2010 at 10:23 AM, zia mohaddes <zia.simab(a)gmail.com> wrote:
> Hi mark,
> 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');
> //$form->addRule(array('cmpPasswd', 'cmpRepeat'), 'The passwords do not
> match', 'compare', null, 'client');
> // add gender
> $genderOptions = array('', 'Male' => 'Male', 'Female' => 'Female',
> 'expected'=>'Expected', 'no_birth'=>'No Birth');
> $this->form->addElement('select', 'gender', 'Gender', $genderOptions);
> // add to form
> //       $this->tpl_data['elements_list'][]="gender";
> // gender rules
> $this->form->addRule('gender', 'Gender is required', 'required');
> $this->form->addFormRule(array(&$this, '_validate'));
> }
> birth_details() is in fact the constructor!
> Thank you kindly,
> for your help!
> regards,
> zia
> On Tue, May 25, 2010 at 9:28 AM, Mark Steudel <msteudel(a)gmail.com> wrote:
>>
>> Those rules look correct, let's see the rest of your form.
>>
>> MS
>>
>> On Tue, May 25, 2010 at 9:23 AM, zia mohaddes <zia.simab(a)gmail.com> wrote:
>> > Hello everyone,
>> >
>> > I am currently using addrule in my quickform as follows to do the
>> > following:
>> >
>> > $this->form->addRule('dob1', 'Date of Birth is required', 'required');
>> > $this->form->addRule(array('dob1', 'dob2'), 'Date of Birth fields must
>> > match', 'compare');
>> >
>> > but unfortunately this doesn't work at all? Am i missing something??
>> >
>> > Thank you kindly for your help in advance!
>> >
>> > regards,
>> >
>> > zia
>> >
>>
>>
>>
>> --
>>
>> -----------------------------------------
>> Mark Steudel
>> P: 206.375.7244
>> msteudel(a)gmail.com
>>
>> . : Work : .
>> http://www.mindfulinteractive.com
>>
>> . : Play : .
>> http://www.steudel.org/blog
>
>



--

-----------------------------------------
Mark Steudel
P: 206.375.7244
msteudel(a)gmail.com

.. : Work : .
http://www.mindfulinteractive.com

.. : Play : .
http://www.steudel.org/blog
From: Alexey Borzov on
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.