Gossamer Forum
Home : Products : DBMan SQL : Discussion :

add multiple - error messages

Quote Reply
add multiple - error messages
Hi,

I'd like to use the add multiple feature in dbman sql 2 to give users the option of adding several records using one form. So I have this:

db.cgi?do=add_multi_form&m=5&db=Company_Product

The problem I have is that if the user decides to add two records, and leaves the remaining records blank, I get a load of error messages like this:

# Column Product Code cannot be left blank.
# Column Category Code cannot be left blank

Is there any way I can tell dbman sql to ignore blank records when adding, so the user gets an add success message for the records he has added?

thanks
Tim Ault
Oxford UK
Quote Reply
Re: [timbo] add multiple - error messages In reply to
Hi,

You need to custom the add_multi_records subroutine a little bit like:

....
foreach my $rec_num ( 1..$rows ) {
# The hash ref, we need, to modify a record.
my $hash = {};

# For through the column names to build our modification hash
foreach my $column ( @columns ) {
$hash->{$column} = $self->{cgi}->{"$rec_num-$column"} if exists $self->{cgi}->{"$rec_num-$column"};
}
next if ($self->{cgi}->{db} eq 'Company_Product' and (!$hash->{category_code} or !$hash->{product_code}));
.....
}

Hope that helps.

TheStone.

B.

Last edited by:

TheStone: Nov 14, 2003, 10:03 AM
Quote Reply
Re: [TheStone] add multiple - error messages In reply to
Thanks, I'll give it a go ...

Well that does suppress the error messages. Thank you!

But it suppresses all error messages - so if there is a problem with adding the records where the user has entered data, they won't get an error message.

Any way you could refine this a bit?

Last edited by:

timbo: Nov 14, 2003, 10:45 AM
Quote Reply
Re: [timbo] add multiple - error messages In reply to
OK, that's working fine now (including the change to get logging working you suggested in the other thread).

I had to make a change to the add_success.html template.

I had
<%include header.html%>
<%ifnot m%>
....
<%Dbsql::HTML::generate_add_success%>
....
<%endif%>
<p>
<%include footer.html%>

I now have

<%include header.html%>
<%ifnot m%>
....
<%Dbsql::HTML::generate_add_success%>
....
<%endif%>
<%if m%>
....
<%Dbsql::HTML::generate_add_success%>
....
<%endif%>
<p>
<%include footer.html%>

Seems to work. Thanks for your help.
Tim Ault
Oxford UK