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