I have a problem with the use of my own validator... Actually, I'd like to
know if validators are only triggered when a value is set.

I explain why this question. You can see a
screenshot<http://thomas.vequaud.free.fr/download/bug_Zend_validation_de_libelle.gif>of
4 tests made on a form. They're all supposed to give me an error cause
all fields are required but the fourth doesn't (label empty whereas levels
("Niv. Requis" and "Niv. Mobilisé") are set). I tried to print everything
from the validator constructor but only the first 3 rows errors are printed,
not the fourth...

So, are validators only triggered when a value is set in a
Zend_Form_Element?!!?!?


Here is a sample of my own form class
for ($i = 1; $i < 7; $i++)
{
// Skill
$skills = new Zend_Form_Element_Textarea('Compétence_'.$i);
[...]
$skills->addValidator(new MyValidatorSkill($i));

// Required level
$niveau_requis = new Zend_Form_Element_Select('Niveau_Requis_'.$i);
[...]
$niveau_requis->addValidator(new MyValidatorLevel($i), true);

// Mobilisé level
$niveau_mobilise = new Zend_Form_Element_Select('Niveau_Mobilisé_'.$i);
[...]
$niveau_mobilise->addValidator(new MyValidatorLevel($i), true);

// 2 skills at least
if ($i < 3)
{
$skills->setRequired(true);
$niveau_mobilise->addValidator(new Zend_Validate_GreaterThan(0));
$niveau_requis->addValidator(new Zend_Validate_GreaterThan(0));
 }
}



2009/2/18 Matthew Weier O'Phinney <[email protected]>:
> -- Thomas VEQUAUD <[email protected]> wrote
> (on Wednesday, 18 February 2009, 05:57 PM +0100):
>> Another question about Zend_Form!
>> I display a table of 11 rows and 3 columns... So 10 rows over 2
>> columns with the same form elements : a textarea element in the second
>> column and a select element in the third. Here is the point: the
>> select element of a specific row is only required when the textarea
>> element of the same row is filled. How I'm supposed to do that?
>>
>> Advices, clues or just URLs appreciated!
>
> Look in the Zend_Form_Element validators documentation, and search for
> the phrase "validator context". :)
>
> --
> Matthew Weier O'Phinney
> Software Architect       | [email protected]
> Zend Framework           | http://framework.zend.com/
>



-- 
Thomas VEQUAUD          http://thomas.vequaud.free.fr/
Expert EPITECH en Ingénierie Informatique
Tél : +33(0)6.50.39.28.10  Fax: +33(0)9.58.46.10.07

Reply via email to