Gossamer Forum
Home : Products : DBMan : Installation :

date fields with no values

Quote Reply
date fields with no values
hello all

trying to implement another DBMAN "instance", so to speak. This would track information when a record is created, then when it is no longer needed, a close date would be entered.

So, when the user creates a record initially, I have a field for date of submission of entry, which gets filled with the &get_date parameter automatically. I have a termination of entry field, which I want to leave blank until sometime in the future, when this entry is no longer valid.

I have everything just like I want it, except when I try to submit the entry, I get a
Error: Unable to Add Record
There were problems with the following fields:
Date_Closed (Invalid date format)

Please fix any errors and submit the record again.

The default.cfg file has the entries in this manner:

Date_Opened => [1, 'date', 12, 15, 1, &get_date, ''],
Date_Closed => [2, 'date', 12, 15, 0, '', ''],


What am I doing wrong?

Thanks

Jamie


------------------
James A. (Jamie) Dennis
*Certified AIX Administrator
*Certified Solaris Administrator
*Member - SAGE, USENIX
Quote Reply
Re: date fields with no values In reply to
You're not doing anything wrong, Jamie. It's the way things are set up in the validate_record subroutine in db.cgi. The check for date format is separate from the check for whether the field is required.

You could do one of several things.

1 -- Until you are ready to use the field, take out the "date" datatype from the .cfg file. When you're ready to use it, put the datatype back in. This is the easiest, but you would probably have to set all your "Date_Closed" fields at the same time.

2 -- Set the Date_Closed field to sometime way in the future -- maybe a year from the creation of the record. You can probably figure out the code you'll need from the "what's new" thing I posted in answer to your other question.

3 -- Edit sub validate_record in db.cgi to look like (in part):

Code:
foreach $col (@db_cols) {
if ($in{$col} =~ /^\s*$/) {
($db_not_null{$col}) and
push(@input_err, "$col (Can not be left blank)");
}
else {
($db_valid_types{$col} && !($in{$col} =~ /$db_valid_types{$col}/)) and
push(@input_err, "$col (Invalid format)");
(length($in{$col}) > $db_lengths{$col}) and
push (@input_err, "$col (Too long. Max length: $db_lengths{$col})");
if ($db_sort{$col} eq "date") {
push (@input_err, "$col (Invalid date format)")
unless &date_to_unix($in{$col});
}
}
}

(I've taken out the comments and changed some of the line breaks so it would look better on the board.)

4 -- Eliminate the field. Set up an "admin-only" link to find expired records, using a similar code to the "what's new." Just set your $days variable to 365 (or whatever) and use "Date-lt" instead of "Date-gt."



------------------
JPD