[html-formfu] DateTime constraint fails? (aka how do I make it a scalar reference?)

Carl Franks fireartist at gmail.com
Tue Mar 17 22:09:22 GMT 2009


2009/3/17 Matija Grabnar <matija at serverflow.com>:
> Given the constraint:
>
>    - type: Text
>      name: start
>      label: From
>      attributes:
>        class: date
>      constraints:
>        - type: DateTime
>          parser:
>            regex: '^\s*(\d{4})-(\d{2})-(\d{2})\s*\d{0,2}:\d{2}:\d{2}\s*$'
>            params: [ year, month, day ]
>
> I get the error:
>
> Caught exception in MyApp::Controller::Root->edit "The 'regex' parameter
> ("^\s*(\d{4})-(\d{2})-(\d{2})\s*\d{0,2}:\d{2}:\d{2}\s*$") to
> DateTime::Format::Builder::Parser::create_single_parser was a 'scalar',
> which is not one of the allowed types: scalarref
>
> Any ideas on what I may be doing wrong? I tried googling it, but got nothing
> that seemed like a solution.

Hmm, maybe it only accepts an actual regex object, and not a string.
Try this in your config:
  regex: !!perl/regexp (^\s*(\d{4})-(\d{2})-(\d{2})\s*\d{0,2}:\d{2}:\d{2}\s*$)

Carl



More information about the HTML-FormFu mailing list