Hi,

don't want to bug you, Carl, but did you have a look at this?


cheers,

moritz


Am 23.04.2008 um 17:00 schrieb Moritz Onken:

Hi,
attached is a test which fails if you add more than one item to a has-many relationship:

I hope I didn't miss a config switch?!


has_many_repeatable_many_new.pl

use strict;
use warnings;
use Test::More tests => 7;

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_many_new.yml');

my $schema = MySchema->connect('dbi:SQLite:dbname=t/test.db');

my $user_rs    = $schema->resultset('User');
my $address_rs = $schema->resultset('Address');

{
   $form->process( {
           'id'                  => '',
           'name'                => 'new nick',
           'count'               => 2,
           'addresses.id_1'      => '',
           'addresses.address_1' => 'new home',
           'addresses.id_2'      => '',
           'addresses.address_2' => 'new office',
       } );

   ok( $form->submitted_and_valid );

   my $row = $user_rs->new({});

   $form->model('DBIC')->update($row);

   my $user = $user_rs->find(1);

   is( $user->name, 'new nick' );

   my @add = $user->addresses->all;

   is( scalar @add, 2 );

   is( $add[0]->id,      1 );
   is( $add[0]->address, 'new home' );

   is( $add[1]->id,      2 );
   is( $add[1]->address, 'new office' );
}

has_many_repeatable_many_new.yml

---
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: Text
       name: address

 - type: Hidden
   name: count

 - type: Submit
   name: submit



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


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

Reply via email to