[html-formfu] warnings using date field
Geoffrey D. Bennett
g at netcraft.com.au
Sat Aug 23 15:13:39 BST 2008
Hi there,
I was getting some warnings from FormFu (0.03003) when trying to use a
date field. Maybe I'm doing something wrong, but my example was
pretty simple:
- type: Date
name: delivery_date
label: Delivery Date
There were many many "Use of uninitialized value in sprintf at
/usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Element/Select.pm line 58."
I'm guessing one per option tag (day, month, and year).
I don't know how it gets to
HTML::FormFu::Element::Select::_string_field() but it comes from
_Group::_parse_option{} when it does "eval { my %x = %$item };"
This patch makes it better for me...
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
--- _Group.pm.orig 2008-08-20 23:23:49.000000000 +0930
+++ _Group.pm 2008-08-23 22:44:28.000000000 +0930
@@ -10,6 +10,8 @@
use Storable qw( dclone );
use Carp qw( croak );
+use Scalar::Util qw( reftype );
+
__PACKAGE__->mk_accessors(qw/ _options empty_first /);
__PACKAGE__->mk_output_accessors(qw/ empty_first_label/);
@@ -108,17 +110,15 @@
sub _parse_option {
my ( $self, $item ) = @_;
- eval { my %x = %$item };
+ my $item_type = reftype($item);
- if ( !$@ ) {
+ if ( $item_type eq "HASH" ) {
# was passed a hashref
return $self->_parse_option_hashref($item);
- }
- eval { my @x = @$item };
- if ( !$@ ) {
+ } elsif ( $item_type eq "ARRAY" ) {
# was passed an arrayref
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
Regards,
--
Geoffrey D. Bennett, RHCE, RHCX mailto:g at netcraft.com.au
Senior Systems Engineer sip:g at netcraft.com.au
NetCraft Australia Pty Ltd http://www.netcraft.com.au/geoffrey/
More information about the HTML-FormFu
mailing list