Devin Austin > Form-Sensible-Reflector-DBIC-0.349 > Form::Sensible::Reflector::DBIC

Download:
Form-Sensible-Reflector-DBIC-0.349.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.349   Source  

NAME ^

Form::Sensible::Reflector::DBIC - A reflector class based on Form::Sensible and Form::Sensible::Reflector

VERSION ^

version 0.349

SYNOPSIS ^

        my $schema = TestSchema->connect('dbi:SQLite::memory:');
        $schema->deploy;
        use Form::Sensible;
        use Form::Sensible::Reflector::DBIC;
        ## name must reflect the table which we are reflecting

        my $dt = DateTime->now;

        my $reflector = Form::Sensible::Reflector::DBIC->new();
        my $form      = $reflector->reflect_from(
            $schema->resultset("Test"),
            {
                form   => { name => 'test' },
                 with_trigger => 1
            }
        );
        my $renderer = Form::Sensible->get_renderer('HTML');

        $form->set_values( { date => $dt } );
        my $output = $renderer->render($form)->complete;

CONFIGURATION OF FIELDS ^

Form::Sensible::Reflector::DBIC was designed with the intention that as much configuration as possible can be done in the definition of the DBIx::Class::ResultSource objects. While the ResultSource definition is used to programatically generate as much of the Form::Sensible::Field definitions as possible, it is possible to add to the Field generated. This is done with several items that can be added to the columinfo hash in the call to add_columns():

validation

The validation hashref is used just as the validation hashref atribute in Form::Sensible::Field. It is typically used by Form::Sensible::Validator in order to create validation rules for form input values. As specified by Form::Sensible::Validator, it can contain keys required, code, and regex.

render_hints

The render_hints hashref also gets passed to Form::Sensible::Field as the render_hints attribute to the create_from_flattened constructor.

fs_definition

The fs_definition hashref can be used to completely override the intelligence ordinarily used to generate the Form::Sensible::Field definition. If this hashref is present, each key in it is used to completely overwrite the key in the Form::Sensible::Field definition. Any of the attributes accepted by Form::Sensible::Field are acceptable here. Note that one could alternatively specify validation and render_hints options here.

For example:

    __PACKAGE__->add_columns(
        'id',
        {
            data_type         => 'integer',
            is_auto_increment => 1,
            is_nullable       => 0
        },
        'phone_number',
        {
            data_type  => 'varchar',
            validation => { regex => qr/[-\d]+/ }, # passed to Form::Sensible::Field
        }
    );
    __PACKAGE__->set_primary_key('id');  # Defaults to hidden in the form

INTERNAL METHODS ^

$self->field_type_map

Hashref of the supported DBMS type->form element translations.

$self->field_class_options

Default options for Form::Sensible field classes.

$self->get_base_definition($name, $datatype)

This gets field definitions for a given datatype and returns them in hashref form.

$self->get_fieldnames()

Get field names for the form, for example, the column names in the table.

$self->get_field_definition()

Get a given field's definition.

CONTRIBUTORS ^

Devin Austin <devin.austin@gmail.com>
Jay Kuri <jayk@cpan.org>
Andrew Moore <amoore@cpan.org>
syntax highlighting: