Skip to content

Commit

Permalink
Compound field with separate declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
Zbigniew Lukasiak committed Apr 20, 2009
1 parent 8102c3e commit 25ff073
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion t/compound_field.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 13;
use Test::More tests => 15;

use lib 't/lib';

Expand Down Expand Up @@ -67,3 +67,31 @@ ok( $dtform->validated, 'form validated' );

is( $dtform->value('start_date')->mdy, '10-02-2008', 'datetime value');

{
package Field::MyCompound;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Field::Compound';

has_field 'aaa' => ( type => 'Text' );
has_field 'bbb' => ( type => 'Text' );
}


{
package Form::TestValues;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';

has_field 'compound' => ( type => '+Field::MyCompound' );
}
my $form = Form::Start->new;
ok( cform, 'Compound form with separate fields declarations created' );

$params = {
'compound.aaa' => 'aaa',
'compound.bbb' => 'bbb',
};
$form->validate( params => $params );
is_deeply( $form->values, { compound => { aaa => 'aaa', bbb => 'bbb' } }, 'Compound with separate fields - values in hash' );


0 comments on commit 25ff073

Please sign in to comment.