use strict; use warnings; use Test::More tests => 5; use HTML::FormFu; my $form = HTML::FormFu->new( { tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } } ); my $field1 = $form->element('Checkboxgroup')->name('foo')->value(2) ->options( [ [ 1 => 'One' ], [ 2 => 'Two' ] ] ); # add element to test non-reversed labels my $field2 = $form->element('Checkboxgroup')->name('foo2') ->options( [ [ 'a' => 'A' ], [ 'b' => 'B' ] ] )->reverse_group(0); # add more elements to test accessor output $form->element('Checkboxgroup')->name('foo3')->options( [ { label => 'Ein', value => 1 }, { label => 'Zwei', value => 2, attributes => { class => 'foobar' } }, ] ); $form->element('Checkboxgroup')->name('bar')->values( [qw/ one two three /] ) ->value('two')->label('My Bar'); my $field1_xhtml = qq{
}; is( "$field1", $field1_xhtml, 'basic checkboxgroup' ); my $field2_xhtml = qq{
}; is( "$field2", $field2_xhtml, 'checkboxgroup with reverse_group off' ); my $form_xhtml = < $field1_xhtml $field2_xhtml
My Bar
EOF is( "$form", $form_xhtml, 'stringified form' ); # With mocked basic query { $form->process( { foo => [ 1, 2, ], bar => 'three', } ); my $foo_xhtml = qq{
}; is( $form->get_field('foo'), $foo_xhtml, 'checkboxgroup after query' ); my $bar_xhtml = qq{
My Bar
}; is( $form->get_field('bar'), $bar_xhtml, 'second checkboxgroup after query' ); }