Yann Kerhervé > Form-Processor-Model-DOD-0.01 > Form::Processor::Model::DOD

Download:
Form-Processor-Model-DOD-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Form::Processor::Model::DOD - Model Class for Form::Processor based on Data::ObjectDriver

VERSION ^

Version 0.01

SYNOPSIS ^

    ## define a form class to use with DOD items
    package MyApplication::Form::User;
    use strict;
    use base 'Form::Processor::Model::DOD';

    # Associate this form with a L<Data::ObjectDriver::BaseObject> class
    sub object_class { 'MyApplication::Model::User' }

    sub profile {
    ...
    }
    1;

DESCRIPTION ^

This is a Form::Processor::Model add-on module. This module is for use with Data::ObjectDriver based objects. By declaring a object_class method in the Form class, a form is tied to the data in the database (typically a row in one table).

The form object can be prefilled with the data from the object in database, and similarily on update_from_form() the object can be inserted or updated in the database (If validation passes).

METHODS ^

object_class

(pod from cdbi model) This method is typically overridden in your form class and relates the form to a specific Class::DBI table class. This is the mapping between the form and the columns in the table the form operates on.

The module uses this information to lookup options in related tables for both select and multiple select (many-to-many) relationships.

If not defined will attempt to use the class of $form->item, if set.

Typically, this method is overridden as shown above, and is all you need to do to use this module. This can also be a parameter when creating a form instance.

init_item

By default, just lookup the item_id associated with that model in the database.

update_from_form

(some parts of this pod section come from cdbi)

    my $ok = $form->update_from_form( $parameter_hash );
    my $ok = $form->update_from_form( $c->request->parameters ); # catalyst for instance

Update or create the object from values in the form.

Validation is run unless validation has already been run. ($form->clear might need to be called if the $form object stays in memory between requests.)

Pass in hash reference of parameters.

Returns false if form does not validate. Very likely dies on database errors.

SEE ALSO ^

Form::Processor, Form::Processor::Model::CDBI, Data::ObjectDriver

AUTHOR ^

Yann Kerherve, <yann.kerherve at gmail.com>

BUGS ^

Please report any bugs or feature requests to bug-form-processor-model-dod at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Form-Processor-Model-DOD. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENT ^

This module is based on the work of Bill Moseley.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Form::Processor::Model::DOD

You can also look for information at:

COPYRIGHT & LICENSE ^

Copyright 2007 Yann Kerherve, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: