| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| 4 |
use HTML::FormHandler::Test; |
| 5 |
|
| 6 |
{ |
| 7 |
package MyApp::Form::Test; |
| 8 |
use HTML::FormHandler::Moose; |
| 9 |
extends 'HTML::FormHandler'; |
| 10 |
with 'HTML::FormHandler::Widget::Theme::Bootstrap'; |
| 11 |
|
| 12 |
has '+name' => ( default => 'testform' ); |
| 13 |
has_field 'foo'; |
| 14 |
has_field 'non_edit' => ( type => 'NonEditable', value => 'This is a Test' ); |
| 15 |
has_field 'bar'; |
| 16 |
|
| 17 |
} |
| 18 |
|
| 19 |
$ENV{LANGUAGE_HANDLE} = 'en_en'; |
| 20 |
|
| 21 |
my $form = MyApp::Form::Test->new; |
| 22 |
$form->process( params => { foo => 'my_foo', bar => 'my_bar' } ); |
| 23 |
|
| 24 |
my $rendered = $form->render; |
| 25 |
my $expected = |
| 26 |
'<form class="form-horizontal" id="testform" method="post"> |
| 27 |
<div class="alert alert-success"> |
| 28 |
<span>Your form was successfully submitted</span> |
| 29 |
</div> |
| 30 |
<div class="control-group"> |
| 31 |
<label class="control-label" for="foo">Foo</label> |
| 32 |
<div class="controls"> |
| 33 |
<input type="text" name="foo" id="foo" value="my_foo" /></div> |
| 34 |
</div> |
| 35 |
<div class="control-group"> |
| 36 |
<label class="control-label" for="non_edit">Non edit</label> |
| 37 |
<div class="controls"> |
| 38 |
<span id="non_edit" />This is a Test</span></div> |
| 39 |
</div> |
| 40 |
<div class="control-group"> |
| 41 |
<label class="control-label" for="bar">Bar</label> |
| 42 |
<div class="controls"> |
| 43 |
<input type="text" name="bar" id="bar" value="my_bar" /></div> |
| 44 |
</div> |
| 45 |
</form>'; |
| 46 |
is_html( $rendered, $expected, 'form with uneditable field renders ok' ); |
| 47 |
|
| 48 |
done_testing; |