[html-formfu] Date Element

Jason Kohles email at jasonkohles.com
Thu Jul 12 19:16:25 GMT 2007


On Jul 12, 2007, at 12:26 PM, Carl Franks wrote:

> On 11/07/07, Tobias Kremer <list at funkreich.de> wrote:
>>
>> So, Carl, may I kindly ask for something like a Date element  
>> because it looks
>> like currently you're the only person capable of implementing this  
>> in a sane
>> way :) FormFu is the best form engine currently available but  
>> without a
>> user-friendly date element it's almost useless for us because  
>> dates are
>> everywhere in our application :( And whose application doesn't  
>> feature dates
>> in at least one form?
>
> Would you propose that from the following input...
>
> day => x,
> month => y,
> year => z
>
> ... $form->params should return:
>
[snip]
> or something else?
>

I've always thought composite widgets should work something like this...

---
elements:
   - type: date
     name: foo

Somewhere in the flow the date type turns this into something like:

elements:
   - type: select
     name: date.month
     options: [Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec]
   - type: select
     name: date.day
     options: [1-31]
   - type: text
     name: date.year

Then have it reassembled after the fact, so that params gets...
{
     date => DateTime->new( year => $year, month => $month, day =>  
$day ),
     'date.day' => $day,
     'date.year' => $year,
     'date.month' => $month,
}

Maybe give FormFu a configuration option for what character you want  
to use to join composite types, so that you have a way out if you are  
using foo.bar as names already, or just declare that composite types  
can't use a period in their subtype names, so if you have a field  
called 'birth.date', you get 'birth.date.day', 'birth.date.year' and  
'birth.date.month', and FormFu would know that only the last element  
is the subtype for composite elements.

-- 
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire





More information about the HTML-FormFu mailing list