| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | use lib 'lib'; | ||
| 5 | use lib 't/lib'; | ||
| 6 | use MyApp::DBSchema; | ||
| 7 | |||
| 8 | { | ||
| 9 | package MyApp::Controller::Form; | ||
| 10 | use HTML::FormHandler::Moose; | ||
| 11 | extends 'HTML::FormHandler::Model::DBIC'; | ||
| 12 | with 'HTML::FormHandler::Render::Simple'; | ||
| 13 | |||
| 14 | |||
| 15 | has '+item_class' => ( default => 'Dvd' ); | ||
| 16 | |||
| 17 | has_field 'tags' => ( type => 'Select', multiple => 1 ); | ||
| 18 | has_field 'name' => ( type => 'TextArea', ); | ||
| 19 | has_field 'submit' => ( widget => 'submit' ); | ||
| 20 | } | ||
| 21 | |||
| 22 | my $schema = MyApp::DBSchema->connect( 'dbi:SQLite:dbname=:memory:' ); | ||
| 23 | $schema->deploy; | ||
| 24 | $schema->resultset( 'Tag' )->create( { name => 'aaa' } ); | ||
| 25 | $schema->resultset( 'Tag' )->create( { name => 'bbb' } ); | ||
| 26 | my $item = $schema->resultset( 'Dvd' )->new_result( {} ); | ||
| 27 | my $form = MyApp::Controller::Form->new( | ||
| 28 | schema => $schema, | ||
| 29 | item => $item, | ||
| 30 | ); | ||
| 31 | |||
| 32 | warn $form->render; | ||
| 33 |