[FLOW3-general] Values for Date (day, month, year) form fields in case of validation errors

Ivan Ruiz Gallego ivan at loglan.net
Thu Nov 24 10:02:29 CET 2011


Hello everyone,

For text fields, selects, textareas, etc. Fluid has view helpers that 
fill the value attribute accordingly to user input in case of validation 
errors. That's a great feature!

But, what happens with properties that need more than a single form 
field? In my case I have a model with a property "birthday" of type 
DateTime.

In my form I have two text fields (day and year) and a select for the 
month. The code looks similar to this:

<f:form.textbox property="birthday.day" />
<f:form.select property="birthday.month" options="{1: 'January', 2: 
'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 
'August', 9: 'September', 10: 'October', 11: 'November', 12: 'December'}" />
<f:form.textbox property="birthday.year" />

On the controller side, I use a type converter to convert the array 
containing day, month and year into the corresponding DateTime object.

In case of validation errors the values of my birthday form fields don't 
get filled by Fluid. I guess Fluid doesn't know what to do with my 
property "birthday.day".

What would be the "elegant" way to solve this issue? At the end of the 
day, I'd like my birthday fields to behave like the other ones. So, 
would it be a good idea to write an own view helper that does the job? 
Or should I modify the model, so that Fluid is able to pre-fill the date 
fields (rather not, I guess!)?

Thanks in advance for you answers.

Regards,
Ivan.


More information about the FLOW3-general mailing list