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,

regards,
oliver.
--

-- 
Oliver Gorwits, Network Infrastructure Group,
Oxford University Computing Services
_______________________________________________
FBusers mailing list
FBusers <at> formbuilder.org
http://www.formbuilder.org/mailman/listinfo/fbusers


Gmane