[html-formfu] Fwd: Model::DBIC: creating many new rows

Moritz Onken onken at houseofdesign.de
Fri Aug 1 11:38:18 BST 2008


>>
>
> Hmm, not sure if you tried running the test ;) the tests failed, the
> count was out - and I don't think the .pm patch does what it should.
> But anyway, moving on...
>
> The only thing I'm not keen on is the similarity between the method
> names 'new_empty_row' and 'new_empty_rows'.
> Too confusing.
>
> Currently, 'new_empty_row' must be set to a column-name or array-ref  
> of names.
> Instead of 'new_empty_rows', how about adding a 'new_empty_row_max'
> (or something similar) which defaults to 1, but can be set to any
> number, and -1 means 'no limit'?

Yes I thought about that name problem too. I think new_empty_row_max  
is fine.
I just thought that putting a constraint on the count field is more  
straight
forward and makes it easier to get the error message if there are more  
rows
than the maximum allowed.

I have no idea why the tests fail. I must have done some last-minute  
changes.

Ahh found it (to add a commented line doesn't make much sense :) ).
The patch should look like this:


Index: lib/HTML/FormFu/Model/DBIC.pm
===================================================================
--- lib/HTML/FormFu/Model/DBIC.pm       (revision 1086)
+++ lib/HTML/FormFu/Model/DBIC.pm       (working copy)
@@ -37,7 +37,7 @@

       return _merge_hashes( $config, $dbic );
   }
-
+    $config->{new_empty_row} ||= $config->{new_empty_rows};
   return $config;
}

@@ -474,7 +474,7 @@
       my $row;

       if (   ( !defined $value || $value eq '' )
-            && $i == $max
+            && ($i == $max || $config->{new_empty_rows})
           && $config->{new_empty_row} )
       {

cheers,

moritz



More information about the HTML-FormFu mailing list