propelorm/sfPropelORMPlugin — pull request #100 by casivaagustin (2011-12-08 22:30:28+00:00)
Title: Problems with Enums Values and White Spaces

Hi Guys, I'm working with enum values using the sfPropelORMPlugin. I
defined this on the schema.

focus: { type: enum, valueSet: "Working on a Startup, Looking for
Startups" , required: false}

As you can see, the enumerated values have white spaces.

When I try to generate the form, the generator alters this values on
choices for the widget and the validator, the result is something like
this

''=>'','WorkingonaStartup'=>'WorkingonaStartup','LookingforStartups'=>'LookingforStartups',

Obviously doesn't work because these aren't the valid values of the
enumeration. So I started to digging into the problem and I can see
that in the sfPropelFormGenerator, when the Generator is preparing the
values for choices makes this replace to get all the code on the same
line (with the objetive to get the generated code well formated, I
presume)

$options[] = sprintf("'choices' => %s", preg_replace('/\s+/',
'', var_export($choices, true)));

The problem with the replacement is that erases the white spaces on
the Enum value, so I think this is a better expresion to make the
replace without delete the spaces.

$options[] = sprintf("'choices' => %s",
preg_replace('/[\n\r]+/', '', var_export($choices, true)));

I'm attaching the patch.

I Hope this will be helpful.