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
|
use strict;
use warnings;
use Test::More tests => 2;
use HTML::FormFu;
my $form = HTML::FormFu->new({ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } });
$form->indicator( sub {1} );
my $field = $form->element('Radiogroup');
$field->name('foo');
$field->values( [qw/ one two /] );
$field->label('My legend');
$field->constraint('Required');
my $xhtml = qq{<fieldset class="radiogroup legend">
<legend>My legend</legend>
<span>
<span>
<input name="foo" type="radio" value="one" />
<label>One</label>
</span>
<span>
<input name="foo" type="radio" value="two" />
<label>Two</label>
</span>
</span>
</fieldset>};
is( "$field", $xhtml );
# With mocked basic query
{
$form->process( {} );
my $xhtml
= qq{<fieldset class="radiogroup legend error error_constraint_required">
<legend>My legend</legend>
<span class="error_message error_constraint_required">This field is required</span>
<span>
<span>
<input name="foo" type="radio" value="one" />
<label>One</label>
</span>
<span>
<input name="foo" type="radio" value="two" />
<label>Two</label>
</span>
</span>
</fieldset>};
is( "$field", $xhtml );
}
|