PageRenderTime 38ms CodeModel.GetById 13ms app.highlight 21ms RepoModel.GetById 2ms app.codeStats 0ms

/t/render_table.t

http://github.com/gshank/html-formhandler
text | 72 lines | 61 code | 11 blank | 0 comment | 0 complexity | f515b402f99dd56fb3944d65e8a6e971 MD5 | raw file
 1use strict;
 2use warnings;
 3use Test::More;
 4
 5use HTML::FormHandler::Field::Text;
 6
 7
 8{
 9   package Test::Form;
10   use HTML::FormHandler::Moose;
11   extends 'HTML::FormHandler';
12   with 'HTML::FormHandler::Render::Table';
13
14   has '+name' => ( default => 'renderform' );
15   has_field 'test_field' => (
16               type => 'Text',
17               label => 'TEST',
18               id    => 'f99',
19            );
20   has_field 'number';
21   has_field 'fruit' => ( type => 'Select' );
22   has_field 'vegetables' => ( type => 'Multiple' );
23   has_field 'opt_in' => ( type => 'Select', widget => 'radio_group',
24      options => [{ value => 0, label => 'No'}, { value => 1, label => 'Yes'} ] );
25   has_field 'active' => ( type => 'Checkbox' );
26   has_field 'comments' => ( type => 'TextArea' );
27   has_field 'hidden' => ( type => 'Hidden' );
28   has_field 'selected' => ( type => 'Boolean' );
29   has_field 'start_date' => ( type => 'DateTime' );
30   has_field 'start_date.month' => ( type => 'Integer', range_start => 1,
31       range_end => 12 );
32   has_field 'start_date.day' => ( type => 'Integer', range_start => 1,
33       range_end => 31 );
34   has_field 'start_date.year' => ( type => 'Integer', range_start => 2000,
35       range_end => 2020 );
36
37   has_field 'two_errors' => (
38       apply => [
39          { check   => [ ], message => 'First constraint error' },
40          { check   => [ ], message => 'Second constraint error' }
41       ]
42   );
43
44   has_field 'submit' => ( type => 'Submit', value => 'Update' );
45
46   has '+dependency' => ( default => sub { [ ['start_date.month',
47         'start_date.day', 'start_date.year'] ] } );
48   has_field 'no_render' => ( widget => 'no_render' );
49   sub options_fruit {
50       return (
51           1   => 'apples',
52           2   => 'oranges',
53           3   => 'kiwi',
54       );
55   }
56
57   sub options_vegetables {
58       return (
59           1   => 'lettuce',
60           2   => 'broccoli',
61           3   => 'carrots',
62           4   => 'peas',
63       );
64   }
65}
66
67my $form = Test::Form->new;
68ok( $form, 'create form');
69
70ok( $form->render, 'get table rendered output from form');
71
72done_testing;