Apache-Wyrd
view release on metacpan or search on metacpan
Wyrd/Form/Preload.pm view on Meta::CPAN
use 5.006;
use strict;
use warnings;
no warnings qw(uninitialized);
package Apache::Wyrd::Form::Preload;
our $VERSION = '0.98';
use base qw (Apache::Wyrd);
=pod
=head1 NAME
Apache::Wyrd::Form::Preload - Wyrd to load a Form Wyrd with existing data
=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
Provides pre-loaded values to the Form Template in which it resides. The
query may return multiple values, in which case it will create an array
of hashrefs data structure appropriate for an
C<Apache::Wyrd::Input::Complex> input if it is flagged to do so with a
"complex" or "multiple" flag.
The preload requires an C<Apache::Wyrd::Query> object to be embedded in
it. It can also accept a C<Apache::Wyrd::Defaults> object.
=head2 HTML ATTRIBUTES
NONE
=head2 PERL METHODS
NONE
=head1 BUGS/CAVEATS/RESERVED METHODS
Reserves the _setup and _generate_output methods.
=cut
sub _setup {
my ($self) = @_;
$self->{'query'} = undef;
$self->{'defaults'} = 'no default available';
}
sub _generate_output {
my ($self) = @_;
my $data = $self->_get_data;
foreach my $key (keys %$data) {
$self->{'_parent'}->{'_variables'}->{$key} = $data->{$key};
}
$self->{'_parent'}->_flags->preload(1);
$self->{'_parent'}->_flags->preloaded(1);
return;
}
=pod
=head1 AUTHOR
Barry King E<lt>wyrd@nospam.wyrdwright.comE<gt>
=head1 SEE ALSO
=over
( run in 1.405 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )