[html-formfu] Bug with Repeatable and Date elements?

Moritz Onken onken at houseofdesign.de
Tue Apr 15 11:04:29 BST 2008


Attached is a test which fails. If you change the Date element to a  
Text element the second test works fine. The output shows that the  
name of the date element isn't transformed to "address_1" I guess.


Index: /Users/mo/Documents/workspace/HTML-FormFu-Model-DBIC/t/update/ 
has_many_repeatable_new_date.t
===================================================================
--- /Users/mo/Documents/workspace/HTML-FormFu-Model-DBIC/t/update/ 
has_many_repeatable_new_date.t	(revision 0)
+++ /Users/mo/Documents/workspace/HTML-FormFu-Model-DBIC/t/update/ 
has_many_repeatable_new_date.t	(revision 0)
@@ -0,0 +1,57 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+use HTML::FormFu;
+use lib 't/lib';
+use DBICTestLib 'new_db';
+use MySchema;
+
+new_db();
+
+my $form = HTML::FormFu->new;
+
+$form->load_config_file('t/update/has_many_repeatable_new_date.yml');
+
+my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');
+
+my $user_rs    = $schema->resultset('User');
+my $address_rs = $schema->resultset('Address');
+
+{
+
+    # insert some entries we'll ignore, so our rels don't have same ids
+    # user 1
+    my $u1 = $user_rs->new_result( { name => 'foo' } );
+    $u1->insert;
+
+}
+
+{
+    $form->process( {
+            'id'                  => 1,
+            'name'                => 'new nick',
+            'count'               => 1,
+            'addresses.address_1_day' => 11,
+            'addresses.address_1_month' => 11,
+            'addresses.address_1_year' => 1985,
+        } );
+
+    ok( $form->submitted_and_valid );
+	for ( @{ $form->get_errors } ) {
+			print Data::Dumper::Dumper({ id => $_->name, msg => $_->message }). 
$/;
+		}
+		
+    $form->process( {
+            'id'                  => 1,
+            'name'                => 'new nick',
+            'count'               => 1,
+            'addresses.address_1' => "12.12.1985"
+        } );
+
+    ok( $form->submitted_and_valid );
+	for ( @{ $form->get_errors } ) {
+			print Data::Dumper::Dumper({ id => $_->name, msg => $_->message }). 
$/;
+		}
+}
+


Index: /Users/mo/Documents/workspace/HTML-FormFu-Model-DBIC/t/update/ 
has_many_repeatable_new_date.yml
===================================================================
--- /Users/mo/Documents/workspace/HTML-FormFu-Model-DBIC/t/update/ 
has_many_repeatable_new_date.yml	(revision 0)
+++ /Users/mo/Documents/workspace/HTML-FormFu-Model-DBIC/t/update/ 
has_many_repeatable_new_date.yml	(revision 0)
@@ -0,0 +1,32 @@
+---
+auto_fieldset: 1
+
+elements:
+  - type: Hidden
+    name: id
+
+  - type: Text
+    name: name
+
+  - type: Repeatable
+    nested_name: addresses
+    counter_name: count
+    model_config:
+      DBIC:
+        new_empty_row: address
+
+    elements:
+      - type: Hidden
+        name: id
+
+      - type: Date
+        name: address
+        constraints:
+          - Required
+
+  - type: Hidden
+    name: count
+
+  - type: Submit
+    name: submit
+




More information about the HTML-FormFu mailing list