| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| 4 |
use HTML::FormHandler::Test; |
| 5 |
use Test::Exception; |
| 6 |
|
| 7 |
{ |
| 8 |
package MyApp::Form::Field::EmailOptin; |
| 9 |
use HTML::FormHandler::Moose; |
| 10 |
extends 'HTML::FormHandler::Field::Checkbox'; |
| 11 |
|
| 12 |
sub build_label { 'Send me expert college planning tips and advice.' } |
| 13 |
has '+default' => (default => 1,); |
| 14 |
sub build_wrapper_class { ['email-optin'] } |
| 15 |
} |
| 16 |
|
| 17 |
{ |
| 18 |
package MyApp::Form::Test; |
| 19 |
use HTML::FormHandler::Moose; |
| 20 |
extends 'HTML::FormHandler'; |
| 21 |
|
| 22 |
has '+field_name_space' => ( default => sub { ['MyApp::Form::Field'] } ); |
| 23 |
|
| 24 |
has_field 'foo' => ( |
| 25 |
type => 'EmailOptin', |
| 26 |
option_wrapper => 'nonexistent', |
| 27 |
); |
| 28 |
has_field 'bar' => ( |
| 29 |
); |
| 30 |
} |
| 31 |
|
| 32 |
my $form = MyApp::Form::Test->new; |
| 33 |
ok( $form, 'form built' ); |
| 34 |
|
| 35 |
dies_ok( sub { $form->render }, 'form dies with error about option_wrapper' ); |
| 36 |
|
| 37 |
done_testing; |