CGI-CRUD
view release on metacpan or search on metacpan
lib/CGI/CRUD/TableIO.pm view on Meta::CPAN
# Perform update operation
# special value of NULL still recognized, however its sufficient to have an empty new value
# where the existing value is not empty, this will update the value to NULL a little more risky but much more
# convenient because values of length < 4 (e.g. YORN and date elements) will have to be expanded to 4
# losing some ability to constrain the values
# THIS MEANS IT IS UP TO YOU TO REPRESENT ALL VALUES IN AN UPDATE, OTHERWISE THEY **WILL BE SET TO NULL**
# e.g. submit a full record to form->add_record and make sure field_template has *all* fields, either by
# completely relying on the data dictionary or inserting a record for all fields in UI_TABLE_COLUMN
sub update_data
{
my ($self,$r) = @_;
my $form = $self->update_form($r) || return undef;
my $q = $r->query();
my %vq = %$q;
map { $vq{$_} =~ s/^NULL$// } keys(%vq);
unless ($form->validate_query(\%vq,$self->{verify_input}))
{
$r->output($form->prepare($q));
return OK;
lib/CGI/CRUD/TableIO.pm view on Meta::CPAN
{
$r->server_error();
return undef;
}
my $msg = qq[<P>Record Updated</P>];
$msg .= $self->return_results($q);
$r->output($msg);
}
# Build update form
sub update_form
{
my ($self,$r) = @_;
my $form = $r->form($r->dbh());
my $table_name = $r->param('__SDAT_TAB_ACTION.TABLE_NAME');
$form->heading("Update $table_name");
$form->action($self->{action});
$form->submit_value('Update');
$r->graceful_add_form_group($form,'DISPLAY EDIT',$table_name,'Edit fields and submit when done') || return undef;
return $form;
}
# Build/present update form
sub update_req
{
my ($self,$r) = @_;
my $form = $self->update_form($r) || return undef;
my $q = $r->query();
$q->{'__SDAT_TAB_ACTION.ACTION'} = 'UD';
my $sq = $form->format_query($q);
my ($table,$rec);
my $table_name = $r->param('__SDAT_TAB_ACTION.TABLE_NAME');
unless (($table = new DBIx::IO::Table($r->dbh(),undef,undef,$table_name)) && ($rec = $table->fetch($sq->{__SDAT}{KEYS})))
{
( run in 0.247 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )