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' } }); my $field = $form->element('Select')->name('foo') ->options( [ [ 1 => 'One' ], [ 2 => 'Two' ] ] ); # add more elements to test accessor output $form->element('Select')->name('foo2')->options( [ { label => 'Ein', value => 1 }, { label => 'Zwei', value => 2, attributes => { class => 'foobar' } }, ] ); $form->element('Select')->name('bar')->values( [qw/ one two three /] ) ->value('two')->label('Bar')->attrs( { id => 'bar' } ); my $field_xhtml = qq{
}; is( "$field", $field_xhtml, 'stringified field' ); my $form_xhtml = < $field_xhtml
EOF is( "$form", $form_xhtml, 'stringified form' ); # With mocked basic query { $form->process( { bar => 'three', } ); my $bar_xhtml = qq{
}; my $bar = $form->get_field('bar'); is( "$bar", $bar_xhtml ); }