There are two things:

 

= >

My complex form is part of a wizard where some of the fields are only displayed on the form depending on choices made in a previous step.

 

These fields are required but only if they are present, that is what I wanted to use the group feature for (with a hidden field).   On second thoughts, I don’t think that will work, so if a validateEmptyField option were available, I could check for emptiness in my custom validator only when appropriate.

 

 

= Two =

I’m getting a bit confused here, but now it seems to me that the group feature cannot be used properly with the new syntax.

 

Basic example:

 

fields:

  date1:

    group:  foo

    myValidator:

      … 

 

  date2:

    group:  foo

    myValidator:

      … 

 

  …otherfields…

 

One would group 2 fields because they are not required, unless one of them is filled in, so required option and msg are not set.

 

Now if date1 is filled in, date2 is checked for emptiness (sfVAlidatorManager.class.php on line 259) and than the default required message (“Required”) is displayed because the msg is not set.

 

Hope I’m making sense here, otherwise please enlighten me J

 

Gert.

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Francois Zaninotto
Sent: maandag 13 november 2006 10:47
To: [email protected]
Subject: [symfony-devs] Re: [symfony-users] Validation: grouped fields problem

 

Hi,

 

If you are referring to the possibility to validate an empty field, this is an enhancement that has to be discussed first. Could you explain us why you need to do that and why the group option doesn't fit your needs?

 

François

 


De : [email protected] [mailto:[email protected]] De la part de Gert Vrebos
Envoyé : lundi 13 novembre 2006 10:25
À : [email protected]
Objet : [symfony-devs] Re: [symfony-users] Validation: grouped fields problem

Hi François,

 

Could you take a look at my first report as well (bottom of this post) as this is not yet fixed (problem exists with both old and new syntax).

 

Gert.

 

                         

Possible Patch (no lime tests run):

 

Index: sfValidatorManager.class.php

===================================================================

--- sfValidatorManager.class.php         (revision 2660)

+++ sfValidatorManager.class.php      (working copy)

@@ -248,6 +248,8 @@

         }

       }

     }

+   

+    $validationNeeded = false;

 

     // now for the dirty work

     if (

@@ -256,20 +258,30 @@

       (!$data['is_file'] && (is_array($value) ? sfToolkit::isArrayValuesEmpty($value) : ($value == null || strlen($value) == 0)))

     )

     {

-      if ($data['required'] || $force)

+      if ($data['required'])

       {

         // it's empty!

         $error  = $data['required_msg'];

         $retval = false;

       }

-      else

+      else if ($force)

       {

+                                              $validationNeeded = true;

+                                  }

+                                  else

+      {

         // we don't have to validate it

         $retval = true;

       }

     }

     else

     {

+                                  $validationNeeded = true;

+                      }

+   

+                     

+                      if ($validationNeeded)

+    {

       // time for the fun

       $error = null;

 

 

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Francois Zaninotto
Sent: vrijdag 10 november 2006 20:38
To: [email protected]
Subject: [symfony-devs] Re: [symfony-users] Validation: grouped fields problem

 

Hi Gert,

 

This bug is fixed in r2655. Thanks for the report!

 

François

 


De : [email protected] [mailto:[email protected]] De la part de Gert Vrebos
Envoyé : vendredi 10 novembre 2006 11:26
À : [email protected]
Objet : [symfony-devs] RE: [symfony-users] Validation: grouped fields problem

In addition, the new validation syntax seems not to support the group parameter… it tries to load ‘group’ as if it was a validator.

 

Gert.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Gert Vrebos
Sent: donderdag 9 november 2006 17:43
To: [EMAIL PROTECTED]
Subject: [symfony-users] Validation: grouped fields problem

 

Hi folks,

 

At validation, if one of the fields in a set of grouped fields is not empty, the other fields are tested for emptiness, independent of their required property.

 

This makes it impossible to run a validator on an empty field (which I need because the field is optional depending on some criteria), but it also differs from the documented behaviour:

 

From the sf book, the example ‘Execute validator on an empty field’:

If Password1=foo and password2=null, the required_message (in this case the default, not very descriptive ‘Required’) is shown instead of the passwordValidator error message.

 

If others consider this as a bug, I will create a ticket with patch.

 

In addition to the group feature, it would be nice to have an option to execute a validator on an empty field as well.  The current dirty workaround I would use is grouping the possibly empty field with a non-empty field, but this is also made impossible by the problem above.  The only solution left now is to validate in the action but I want to avoid that.

 

Gert.

 

 




--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to