|
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:
Hi
Gert, This bug is fixed in
r2655. Thanks for the report! François De :
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:
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 -~----------~----~----~----~------~----~------~--~--- |
- [symfony-devs] RE: [symfony-users] Validation: ... Gert Vrebos
- [symfony-devs] Re: [symfony-users] Validat... Francois Zaninotto
- [symfony-devs] Re: [symfony-users] Val... Gert Vrebos
- [symfony-devs] Re: [symfony-users]... Francois Zaninotto
- [symfony-devs] Re: [symfony-us... Gert Vrebos - Tactics bvba
