Tobias Kremer | 23 Jan 10:57

[FormBuilder] Date fields

Hey folks,

I just started playing around with FB and I wonder if you can suggest some
possibilities to include nice date fields into a form? I don't want my users
to enter error-prone MM/DD/YYYY dates in a stupid text field but rather I'd
like to have three select lists (monthnames, day, yearlist) per date field.

Before I started to use FB I had a homegrown form solution which had an
additional "date" fieldtype that spit out those three columns and
verified the date.

AFAICT from looking at the FB source this should be doable by adding something
like a CGI::FormBuilder::Field::date class, right? Has somebody here already
tried something like this?

Thanks for any suggestions!

--Tobias
_______________________________________________
FBusers mailing list
FBusers <at> formbuilder.org
http://www.formbuilder.org/mailman/listinfo/fbusers

Oliver Gorwits | 23 Jan 11:25
Favicon
Gravatar

Re: [FormBuilder] Date fields

Tobias Kremer wrote:
> AFAICT from looking at the FB source this should be doable by adding something
> like a CGI::FormBuilder::Field::date class, right? Has somebody here already
> tried something like this?

It sounds like we've both been down the same road!

I store epochs in my DB for "datetime" type things. The example I 
provide is not complete, but it does work, although it's written for 
Catalyst (you can spot the use of $form->c):

    http://scsys.co.uk:8001/6239?hl=on
    [subclassing CGI::FormBuilder Fields, at noPaste]

There are two things which make this tricky...

1) CGI::FormBuilder will look up hints for error strings for 
form_invalid_datetime and js_invalid_datetime, but they don't exist. I 
have some code which hacks around this, although Nate recently suggested 
an alternative method:

http://comments.gmane.org/gmane.comp.lang.perl.modules.formbuilder/904

2) Form validation can be awkward because you're exploding one item of 
data out into three, or more, and you probably want to recombine them 
for validation/storage. This can be worked around, but it depends on 
what framework you're using CGI::FormBuilder with (e.g. Catalyst, etc).

HTH,

(Continue reading)


Gmane