The docs for HTML::FormFu::Inflator::DateTime have the following
(slightly boiled down) example:

      - type: Text
        name: end_time
        inflators:
          - type: DateTime
            parser:
              regex: '^ (\d{2}) - (\d{2}) - (\d{4}) $'

On my machine, with HTML::FormFu 0.3001 and DateTime::Format::Builder
0.7901, this results in:

Caught exception in ... "The 'regex' parameter ("^ (\d{2}) - (\d{2}) -
(\d{4}) $") to DateTime::Format::Builder::Parser::create_single_parser
was a 'scalar', which is not one of the allowed types: scalarref
 at /usr/local/share/perl/5.8.8/DateTime/Format/Builder/Parser.pm line 311

DateTime::Format::Builder::Parser expects the "regex" parameter to be
a scalar ref containing a compiled regex, so the string supplied in
the example won't work. This patch fixes it:

===================================================================
--- FormFu/Inflator/DateTime.pm (revision 1089)
+++ FormFu/Inflator/DateTime.pm (working copy)
@@ -19,10 +19,14 @@

 sub parser {
     my $self = shift;
+       my $arg = shift;

-    $self->_builder->parser(@_);
+       my $regex = $arg->{regex};
+       $arg->{regex} = qr/$regex/ if $regex;

-    return $self;
+       $self->_builder->parser($arg);
+
+       return $self;
 }

Any objections to me committing this? Anything I've missed?

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to