use strict; use warnings; use Test::More tests => 3; use HTML::FormFu; my $form = HTML::FormFu->new({ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } }); $form->element('Radiogroup')->name('foo')->default(2)->options( [ { group => [ [ 1 => 'one' ], [ 2 => 'two' ] ] }, { group => [ [ foo2_1 => 'One' ], [ foo2_2 => 'Two' ] ], label => 'foo2', }, [ x => 'non-opt' ], { group => [ { label => 'wun', value => 'foo3_1' }, { label => 'too', value => 'foo3_2', attributes => { class => 'foo3b' }, container_attributes => { class => 'item foo3_2' }, }, ], label => 'foo3', attributes => { class => 'opt4' }, }, ] ); my $expected_form_xhtml = <
EOF is( "$form", $expected_form_xhtml ); # With mocked basic query { $form->process( { foo => 'foo3_1', } ); my $xml = $form->get_field('foo'); like( "$xml", qr/value="foo3_1" checked="checked"/ ); my $count = $xml =~ s/checked="checked"/checked="checked"/g; is( $count, 1 ); }