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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
use strict;
use warnings;
use Test::More tests => 11;
use HTML::FormFu;
use lib 't/lib';
use HTMLFormFu::TestLib;
my $form = HTML::FormFu->new;
$form->load_config_file('t/repeatable/constraints/required_not_nested.yml');
$form->get_element( { type => 'Repeatable' } )->repeat(2);
# Valid
{
$form->process( {
foo_1 => 'a',
bar_1 => 'b',
foo_2 => 'c',
bar_2 => 'd',
count => 2,
} );
ok( $form->submitted_and_valid );
is_deeply(
$form->params,
{
foo_1 => 'a',
bar_1 => 'b',
foo_2 => 'c',
bar_2 => 'd',
count => 2,
} );
}
# Missing - Invalid
{
$form->process( {
bar_1 => 'b',
foo_2 => 'c',
count => 2,
} );
ok( !$form->submitted_and_valid );
ok( $form->has_errors('foo_1') );
ok( !$form->has_errors('bar_1') );
ok( !$form->has_errors('foo_2') );
ok( $form->has_errors('bar_2') );
like( $form->get_field( 'foo_1' ), qr/error/ );
unlike( $form->get_field( 'bar_1' ), qr/error/ );
unlike( $form->get_field( 'foo_2' ), qr/error/ );
like( $form->get_field( 'bar_2' ), qr/error/ );
}
|