Gossamer Forum
Home : Products : DBMan : Customization :

Auto "na" insert

Quote Reply
Auto "na" insert
I'm looking for a way to automatically insert "na", as in "not available", into the text database when a user does not fill in a field.

Basically, I'm too darn lazy to research the code snippet myself and I'm wondering if anyone can tell me where it needs to go and the code that will say..

if field(isEmpty){
insertIntoDB('na');
}
else{
insertIntoDB(feildcontents)
}

Any assistance would be greatly appreciated.

Thanks
J.D.M.
Quote Reply
Re: Auto "na" insert In reply to
Make the default value "na" for each of your non-required fields. You can do this in the default.cfg file with no scripting at all.


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





Quote Reply
Re: Auto "na" insert In reply to
Well, I can do that for the non-date fields. However, I need the software itself to insert the "NA" directly into the database because it reads the date feilds and if there isn't any input it gives the user an error. So i need to have something "hold the spot" unitl they get a date to put in its place.

What do you think?
Quote Reply
Re: Auto "na" insert In reply to
You can disable the error checking for the date field if you'd like.

In sub validate_record (db.cgi), comment out the lines:

Code:
if ($db_sort{$col} eq "date") {
push (@input_err, "$col (Invalid date format)") unless &date_to_unix($in{$col});
}

Or, you could insert a date in there by default, like "01-Jan-1970."


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