Class-DBI-FormBuilder

 view release on metacpan or  search on metacpan

lib/Class/DBI/FormBuilder.pm  view on Meta::CPAN

=item update_from_form( $form )

Updates an existing CDBI object. 

If called on an object, will update that object.

If called on a class, will first retrieve the relevant object (via C<retrieve_from_form>).

=cut

sub update_from_form 
{
    my ( $proto, $form ) = @_;
    
    my $them = ref( $proto ) ? $proto : $proto->retrieve_from_form( $form );
    
    Carp::croak "No object found matching submitted primary key data" unless $them;
    
    my $me = $proto->__form_builder_subclass__;
    
    $me->_run_update( $them, $form );

lib/Class/DBI/FormBuilder.pm  view on Meta::CPAN

=item update_or_create_from_form

Class method.

Attempts to look up an object (using primary key data submitted in the form) and update it. 

If none exists (or if no values for primary keys are supplied), a new object is created. 

=cut

sub update_or_create_from_form
{
    my ( $them, $form ) = @_;
    
    Carp::croak "update_or_create_from_form can only be called as a class method" if ref $them;

    $them->__form_builder_subclass__->_run_update_or_create_from_form( $them, $form );
}

sub _run_update_or_create_from_form
{



( run in 0.233 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )