use strict;
use warnings;
use Test::More tests => 7;
use HTML::FormFu;
use DateTime;
my $dt = DateTime->new( month => 8, year => 2007 );
my $form = HTML::FormFu->new({ tt_args => { INCLUDE_PATH => 'share/templates/tt/xhtml' } });
$form->element('Date')->name('foo')
->default($dt)
->field_order( [ qw/ month year / ])
->strftime('%m/%Y')
->month( {
prefix => '-- Month --',
short_names => 1,
} )
->year( {
prefix => '-- Year --',
list => [ 2007 .. 2017 ],
} )
->auto_inflate(1)
->constraint('Required');
$form->element('Date')->name('bar')
->default('08-2007')
->field_order( [ qw/ year month / ] )
->strftime('%m-%Y')
->year( { list => [ 2007 .. 2017 ] } );
$form->process;
is( "$form", <
HTML
$form->process( {
'foo_month', 6, 'foo_year', 2007,
'bar_month', 7, 'bar_year', 2007,
} );
ok( $form->submitted_and_valid );
my $foo = $form->param('foo');
my $bar = $form->param('bar');
isa_ok( $foo, 'DateTime' );
ok( !ref $bar );
is( $foo, "06/2007" );
is( $bar, "07-2007" );
is( "$form", <
HTML