Apache-Wyrd

 view release on metacpan or  search on metacpan

Wyrd/SQLForm.pm  view on Meta::CPAN

use 5.006;
use strict;
use warnings;
no warnings qw(uninitialized);

package Apache::Wyrd::SQLForm;
our $VERSION = '0.98';
use base qw(Apache::Wyrd::Form);
use Apache::Wyrd::Services::SAK qw(:db);
use warnings qw(all);
no warnings qw(uninitialized);

=pod

=head1 NAME

Apache::Wyrd::SQLForm - General Form Wyrd for editing data in SQL

=head1 SYNOPSIS

    <BASENAME::SQLForm index="user_id" table="users">
      <BASENAME::Form::Template name="password">
        <BASENAME::Form::Preload>
          <BASENAME::Defaults>
            select 'root' as user_id;
          </BASENAME::Defaults>
          <BASENAME::Query>
            select user_id from users where name='Groucho'
          </BASENAME::Query>
        </BASENAME::Form::Preload>
        <b>Enter Password:</b><br>
        <BASENAME::Input name="password" type="password" />
        <BASENAME::Input name="user_id" type="hidden" />
      </BASENAME::Form::Template>
      <BASENAME::Form::Template name="result">
        <H1>Status: $:_status</H1>
        <HR>
        <P>$:_message</P>
      </BASENAME::Form::Template>
    </BASENAME::SQLForm>

=head1 DESCRIPTION

The SQLForm is a subclass of Apache::Wyrd::Form.  It is meant to simplify
the creation of forms that are used to edit data within a database connected
to via the C<Apache::Wyrd::DBL>.

The SQLForm makes the assumption that there is a primary table on which the
edit is operating and that other tables will, if necessary, have elements
inserted, changed or deleted from them as they relate to the primary table.

This module is meant to be subclassed, so a large number of its methods are
only defined in order to be overridden.  Any changes to secondary tables,
for example, need to be handled by subclassing C<_prep_secondary>,
C<_submit_secondary>, and C<_perform_secondary_deletes>, all of which do
nothing by default.

=head2 HTML ATTRIBUTES

=over

=item index

The index column of the primary table, i.e. the name of the primary key column.

=item table

The name of the primary table.

=back

=head2 PERL METHODS

I<(format: (returns) name (arguments after self))>

=over

=item (scalar) C<cancelled> (void)

Determine if the action has been cancelled.  Defaults to assuming the form is cancelled if the action parameter is set to B<cancel>.

=cut

sub cancelled {
	my ($self) = @_;
	if ($self->dbl->param('action') eq 'cancel') {
		$self->_set_feedback('Cancelled', '<BR>No changes were made to the Record');
		return 1;
	}
	return;
}



( run in 1.477 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )