1use strict;
2use warnings;
3
4use Test::More tests => 1;
5
6use HTML::FormFu;
7
8my $form = HTML::FormFu->new;
9
10$form->populate(
11    {   elements => [
12            { type => 'Hidden', name => 'count' },
13            {   type         => 'Repeatable',
14                nested_name  => 'rep',
15                counter_name => 'count',
16                elements     => [
17                    { type => 'Text', name => 'title' },
18                    { type => 'Text', name => 'title2' } ] } ] } );
19
20$form->get_element( { nested_name => 'rep' } )->repeat(2);
21
22$form->process(
23    { 'rep_1.title' => 'foo', 'rep_1.title2' => 'bar', 'rep_2.title' => 'foo' }
24);
25
26is_deeply(
27    $form->model('HashRef')->create,
28    {   count => undef,
29        rep   => [
30            { title => 'foo', title2 => 'bar' },
31            { title => 'foo', title2 => undef } ] } );
32