File: belongs_to_create_required.t

package info (click to toggle)
libhtml-formfu-model-dbic-perl 0.09002-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,064 kB
  • sloc: perl: 2,270; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use strict;
use warnings;
use Test::More tests => 2;

use HTML::FormFu;
use lib 't/lib';
use DBICTestLib 'new_schema';
use MySchema;

my $form = HTML::FormFu->new;

$form->populate({
    elements => [
        {
            name => 'band',
        },
        {
            type => 'Block',
            nested_name => 'manager',
            elements => {
                name => 'name',
            }
        }
    ]
});

my $schema = new_schema();

my $rs = $schema->resultset('ManagedBand');
my $band = $rs->new_result({});

$form->process({ band => 'The Foobars', 'manager.name' => 'Mr Foo' });

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

is($band->band, 'The Foobars');
is($band->manager->name, 'Mr Foo');