On 20/04/07, Thorsten Domsch <[EMAIL PROTECTED]> wrote:
I want to create a custom FormFu Element consisting out of a few ordinary HTMl Elements via formFu. Let's say a 
date combo consisting of three select boxes (Day,Month,Year named $self->name."_d", "_m" 
,"_y"), creating something like this is easy, writing the three boxes in my template file childsplay, 
but how do i get formfu to correctly evaluate the three boxes as one (constraints, errormsgs ??) ??

Error messages should already be handled properly - meaning errors
from all sub-elements will be displayed together, in the same manner
as non-multi elements.
For an example, see the "Multi, 3 Select fields" element in this demo page:
http://www.fireartist.com/html-formfu-cssapp/form/view/with-errors/1

So if you want to check for a valid date, you would only need one
constraint added to one element, and then make the error message
appropriate for the 3 fields as a whole.

I haven't copied the old HTML::Widget::Constraint::Date into form,
because I wanted it to also support single-field dates, and not just
separate year/month/day fields.

The way I think I'd like to see it work, would be that if you're using
a single field for the whole date, that you'd use the same interface
as HTML::FormFu::Inflator::DateTime - providing an argument suitable
for DateTime::Format::Builder::parser()

---
elements:
 - type: text
   name: date
   constraints:
     - type: Date
       parser:
         strptime: '%d-%m-%Y'

or

---
elements:
 - type: text
   name: date
   constraints:
     - type: Date
       parser:
         regex: '^ (\d{2}) - (\d{2}) - (\d{4}) $/'
         params: [day, month, year]

Or if you want to use 3 seperate fields, I think the constraint should
probably use the same other() interface as several other constraints
already do - as I plan to standardize this soon, and make them all use
a common base-class. (part of the reason for this is to help the work
I've been doing on the client-side JS constraints).
So, it's probably okay to say that the constraint has to be added to
the 'year' field, and others() names the 'month' and 'day' fields.
Like so:

---
elements:
 - type: multi
   elements:
     - type: text
       name: year
       constraints:
         - type: Date
           others: [month, day]
     - type: text
       name: month
     - type: text
       name: day

Patches / commits to actually implement HTML::FormFu::Constraint::Date welcome!

Carl

_______________________________________________
Html-widget mailing list
Html-widget@lists.rawmode.org
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget

Reply via email to