Today I upgraded my project form PR9 to PR10. There was some necessary
changes here and there but everything was very smooth, except one
part: validation. I found 2 (possible) issues:
1- src/XXX/MyBundle/Resources/config/validation.yml has no effect
anymore:
seems like this file is being ignored in PR10. No matter what
I put inside, even badly formatted yml, nothing happens. I converted
my .yml file into a .xml and it works.
2- I noticed something weird with Choice validator. Give the
following form:
class AirportStateForm extends Form {
protected function configure() {
$this->add(new ChoiceField('state',array(
'choices' => array(1=>"Option 1",2=>"Option 2"),
'expanded' => true,
'multiple' => false
)));
}
}
and the following validator:
<property name="state">
<constraint name="NotBlank">
<option name="message">Choose an option</option>
</constraint>
<constraint name="Choice">
<option name="choices">
<value>1</value>
<value>2</value>
</option>
<option name="message">Invalid choice</option>
</constraint>
</property>
This form is a set of radio buttons, as specified by "expanded" and
"multiple" options. Let's say I add an extra radio to the group with
value = 3 (manually in the template, just to test the validator).
Validator should catch this as an invalid choice, but instead, the
NotBlank is triggered AND, another error (a Form default validator) is
triggered, saying: "This form should not contain extra fields". Looks
like it treats this invalid choice as a NEW field and the "state"
field is treated as blank, therefore it trigger both errors. The same
happens if the field is converted into a select box.
I can confirm that any of these errors happened before the upgrade, so
it looks like something broke in PR10. I'm just not sure if I was
running PR8 or PR9 before, but sure enough everything was working
properly.
That's it, I hope to have contributed a little bit with Symfony
community.
Carlos Barros
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
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