HTML-FormHandler

 view release on metacpan or  search on metacpan

t/render/simple.t  view on Meta::CPAN

</div>',
   'output from text field');

my $output2 = $form->render_field( $form->field('fruit') );
is_html( $output2,
   '
<div><label class="label" for="fruit">Fruit</label><select name="fruit" id="fruit"><option value="1" id="fruit.0">apples</option><option value="2" id="fruit.1" selected="selected">oranges</option><option value="3" id="fruit.2">kiwi</option></select>
</div>',
   'output from select field');

my $output12 = $form->render_field( $form->field('cheese') );
is_html( $output12,
   '
<div><label class="label" for="cheese">Cheese</label><select name="cheese" id="cheese"><option value="1" id="cheese.0">canastra</option><option value="2" id="cheese.1" disabled="disabled">brie</option><option value="3" id="cheese.2">gorgonzola</optio...
</div>',
   'output from select field with disabled option');

my $output3 = $form->render_field( $form->field('vegetables') );
is_html( $output3,
   '
<div><label class="label" for="vegetables">Vegetables</label><select name="vegetables" id="vegetables" multiple="multiple" size="5"><option value="1" id="vegetables.0">lettuce</option><option value="2" id="vegetables.1" selected="selected">broccoli</...
</div>',
'output from select multiple field');

my $output13 = $form->render_field( $form->field('grains') );
is_html( $output13,
   '
<div><label class="label" for="grains">Grains</label><select name="grains" id="grains" multiple="multiple" size="5"><option value="1" id="grains.0">maize</option><option value="2" id="grains.1" disabled="disabled">rice</option><option value="3" id="g...
</div>',
'output from select multiple field with disabled option');

my $output4 = $form->render_field( $form->field('active') );
is_html( $output4,
   '
<div><label class="label" for="active">Active</label><input type="checkbox" name="active" id="active" value="1" />
</div>',
   'output from checkbox field');

my $output5 = $form->render_field( $form->field('comments') );
is_html( $output5,
   '
<div><label class="label" for="comments">Comments</label><textarea name="comments" id="comments" rows="3" cols="40">Four score and seven years ago...</textarea>
</div>',
   'output from textarea' );

my $output6 = $form->render_field( $form->field('hidden') );
is_html( $output6,
   '<div><input type="hidden" name="hidden" id="hidden" value="1234" /></div>',
   'output from hidden field' );

my $output7 = $form->render_field( $form->field('selected') );
is_html( $output7,
   '
<div><label class="label" for="selected">Selected</label><input type="checkbox" name="selected" id="selected" value="1" checked="checked" />
</div>',
   'output from boolean' );

my $output8 = $form->render_field( $form->field('start_date') );
is_html( $output8,
   '
<fieldset class="start_date" id="start_date"><legend>Start date</legend>
<div><label class="label" for="start_date.month">Month</label><input type="text" name="start_date.month" id="start_date.month" size="8" value="7" />
</div>
<div><label class="label" for="start_date.day">Day</label><input type="text" name="start_date.day" id="start_date.day" size="8" value="14" />
</div>
<div><label class="label" for="start_date.year">Year</label><input type="text" name="start_date.year" id="start_date.year" size="8" value="2006" />
</div>
</fieldset>',
   'output from DateTime' );

my $output9 = $form->render_field( $form->field('submit') );
is_html( $output9, '
<div><input type="submit" name="submit" id="submit" value="Update" />
</div>', 'output from Submit');

my $output10 = $form->render_field( $form->field('opt_in') );
is_html( $output10, '
<div><label class="label" for="opt_in">Opt in</label> <br /><label for="opt_in.0"><input type="radio" value="0" name="opt_in" id="opt_in.0" checked="checked" />No</label><br /><label for="opt_in.1"><input type="radio" value="1" name="opt_in" id="opt_...
</div>', 'output from radio group' );

my $output11 = $form->render_start;
is_html( $output11,
'<form id="testform" method="post"><fieldset class="form_wrapper">',
'Form start OK' );

my $output = $form->render;
ok( $output, 'get rendered output from form');

is_html( $form->render_field( $form->field('no_render')), '', 'no_render' );

done_testing;



( run in 0.864 second using v1.01-cache-2.11-cpan-39bf76dae61 )