File: active_column.t

package info (click to toggle)
libhtml-formhandler-model-dbic-perl 0.29-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: perl: 1,873; sql: 259; makefile: 14
file content (34 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use Test::More;
use lib 't/lib';
use BookDB::Schema;

{
    package MyApp::Form::Test;
    use HTML::FormHandler::Moose;
    extends 'HTML::FormHandler::Model::DBIC';

    has '+item_class' => ( default => 'Book' );
    has_field 'title' => (
        type             => 'Text',
        required         => 1,
    );

    # has_many relationship pointing to mapping table
    has_field 'genres' => (
        type         => 'Multiple',
        label_column => 'name',
        active_column => 'is_active',
    );
}

my $schema = BookDB::Schema->connect('dbi:SQLite:t/db/book.db');
my $form = MyApp::Form::Test->new( schema => $schema );

ok( $form );

is( $form->field('genres')->num_options, 3, 'right number of options' );

done_testing;