Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Working on a better confirm ...

Quote Reply
Working on a better confirm ...
Hi there, im still not confident with my mod for confirmation after add and modify.
Have some things changed. Now first add something then the data is proved then the confirmation comes up.
(Bevore you must first confirm then tru the proving)

Cause its not very language- and user-friendly, i have erased the error-message (Title not filled up ...)

now im looking for the following:

In add.cgi:

# Validate the form input..
$rec = &cgi_to_hash ( $in );
$id = $val->add_record ( $rec, $in );

##--## Ok?
if ($id) { ......

Here i need a function that erases all fields not ok for the validate table.

If user comes to the add_error, he gets all filled in values into the form-fields; i want this values to be erased
or to set to "error" or the best version: erased and a small new tag set that marks the field.

(I have happilly remarked that the if, ifnots are working in the add_templates. I really love this script.


Quote Reply
Re: Working on a better confirm ... In reply to
Ok; found in dbsql.pm

sub add_record {
# Validate the record.
my $status = $self->_validate_record($rec_r);
if ($status ne "ok") { return $self->error('VALIDATE', $status); }
jumps to: _validate_record, this returns ok or not; if not we jump back to add.cgi and call add_error.

sub _validate_record {
# --------------------------------------------------------
# Verifies that a record meets any validation requirements.
my ($self, $rec_r) = @_;

# We check that the record is not null, passes a valid regexpression
# and is not too long.
my %not_null = %{$self->{'db_not_null'}};
my %valid_type = %{$self->{'db_valid_types'}};
my %max_length = %{$self->{'db_max_length'}};
my @errors = ();
my $output = '';

foreach my $column (@{$self->{'db_cols'}}) {
next if ($column eq $self->{'db_key'}); # This will be auto-generated
if ($rec_r->{$column} =~ /^\s*$/) {
$not_null{$column} and push (@errors, "$column (Can not be left blank)");
else {
if ($valid_type{$column} and !($rec_r->{$column} =~ /$valid_type{$column}/)) {
push (@errors, "$column (Invalid format)");
if ($max_length{$column} and (length $rec_r->{$column} > $max_length{$column})) {
push (@errors, "$column (Too long. Max length: $max_length{$column}");
if (@errors) {
$output = join ("<li>\n", @errors);
$output = "<ul><li>$output</ul>";
return $output;
return "ok";

Hmmm, so many vars; and im glad not to knoe which one are vars, pointers or arrays :-)

Puuuuuuuuuuuuuuuuuugdooooooooooooooog, help me.