Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix unintialized warning processing has_field with '+'

  • Loading branch information...
commit 44918fe21637c4c1cdc3c2ab96823e9a35300c8c 1 parent 5534a31
Gerda Shank authored
3  lib/HTML/FormHandler/BuildFields.pm
View
@@ -391,8 +391,9 @@ sub _update_or_create {
$field = $parent->field( $field_attr->{name} );
die "Field to update for " . $field_attr->{name} . " not found"
unless $field;
- delete $field_attr->{name};
foreach my $key ( keys %{$field_attr} ) {
+ next if $key eq 'name' || $key eq 'form' || $key eq 'parent' ||
+ $key eq 'full_name' || $key eq 'type';
$field->$key( $field_attr->{$key} )
if $field->can($key);
}
4 lib/HTML/FormHandler/Field.pm
View
@@ -222,8 +222,8 @@ The order attribute may be used to set the order in which fields are rendered.
The following are discouraged. Use 'element_attr', 'label_attr', and 'wrapper_attr'
instead.
- css_class - instead use wrapper_attr => { class => '...' }
- input_class - instead use element_attr => { class => '...' }
+ css_class - instead use wrapper_class => [ '...' ]
+ input_class - instead use element_class => [ '...' ]
title - instead use element_attr => { title => '...' }
style - instead use element_attr => { style => '...' }
tabindex - instead use element_attr => { tabindex => 1 }
33 t/field_setup/plus_field.t
View
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+use Test::More;
+
+{
+ package MyApp::Form::Test;
+ use HTML::FormHandler::Moose;
+ extends 'HTML::FormHandler';
+
+ has_field 'foo';
+
+ with 'MyApp::Form::Role::Factors';
+
+ has_field '+bar_one' => ( accessor => 'dimension_value_ids' );
+ has_field '+bar_two' => ( accessor => 'factor_value_ids' );
+}
+
+
+{
+ package MyApp::Form::Role::Factors;
+
+ use HTML::FormHandler::Moose::Role;
+
+ has_field bar_one => ( type => 'Repeatable', required => 0 );
+ has_field 'bar_one.contains' => ( type => 'Integer' );
+ has_field bar_two => ( type => 'Repeatable', required => 0 );
+ has_field 'bar_two.contains' => ( type => 'Integer' );
+}
+
+my $form = MyApp::Form::Test->new;
+ok( $form );
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.