The problem is that:

@assert:Choice(choices = {"male", "female"}, message = "Choose a valid
gender.")

tells the validator that the value should be either "male" or
"female",
while the widget choices are array(0 => 'male', 1 => 'female'), "0"
and "1" being the values and "male" and "female" the option labels.

You should probably enter a defect in the system for that.

Regards,
Victor

On May 16, 12:21 pm, John Wards <[email protected]> wrote:
> Okay I've added a Choice constraint to my Form Demo 
> bundlehttps://github.com/johnwards/FormDemoBundle
>
> https://github.com/johnwards/FormDemoBundle/blob/master/Entity/Resear...
>
> Basically the Researcher won't validate against beta1 now, unless I've
> done the Constraint wrong?
>
>
>
>
>
>
>
> On Mon, May 16, 2011 at 11:13 AM, John Wards <[email protected]> wrote:
> > So I was testing out a pull request with Choices, and setup a simple
> > Choice constraint based on the one listed here:
>
> >http://symfony.com/doc/2.0/reference/constraints/Choice.html
>
> > It failed validation, so I checked out a clean symfony/master and
> > tried again and it still failed.
>
> > It seems that the form is rendering the "gender" field like this:
>
> >    <select><option value='0'>male</option><option
> > value='1'>female</option></select>
>
> > However the ChoiceValidator is doing:
>
> >    elseif (!in_array($value, $choices, true)) {
> >        //set error..
>
> > The value is 0||1, if I use firebug and change the value to
> > male||female the validator is happy with that.
>
> > Now is this a rendering issue in the form component? Or a bug in the
> > Validator? Or am I being stupid?
>
> > John

-- 
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

Reply via email to