Gossamer Forum
Home : Products : DBMan : Customization :

&get_date in modify form

Quote Reply
&get_date in modify form
Here is the scoop: When someone adds a record, the date gets added in a hidden field (so they can't change it). Whenever someone modifies a record, I would like it to &get_date so I can have a "Last Modified" field instead of "Date Entered". I currently have it like so:
Code:
<input type="hidden" name="Date" value="$rec{'Date'}" size="12" maxlength="15">
That way they can't change the date to whatever they want. I tried this:
Code:
<input type="hidden" name="Date" value="&get_date" size="12" maxlength="15">
... but as you probably know, it didn't work because that sub function is in db.cgi instead of html.pl and & won't work within the quotes. So I tried copying the sub function to html.pl and using value="$get_date" which is probably the wrong way because it didn't work. I don't know much about perl, so I just guessed. =) Thanks for your help

Nelson
Quote Reply
Re: &get_date in modify form In reply to
Here is the code I added to 'sub html_record_form' in html.pl after my (%rec) = @_;:
Code:
if ($in{'modify_form_record'}) {
$rec{'Date'} = &get_date;
$rec{'Time'} = &get_time;
}

Change the INPUT lines back to what you had them before you tried to do the &get_date stuff:

<INPUT TYPE="TEXT" NAME="Date" VALUE="$rec{'Date'}" ...>
<INPUT TYPE="TEXT" NAME="Time" VALUE="$rec{'Time'}" ...>

The dots are there because I changed the size of my fields, so set them to what you had them before.

Hope this helps. I wanted to do the same thing, so you may encounter another problem. See message thread:
www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/002843.html
for a possible fix to the 'sub get_date'

Hope this helps,
AJ

[This message has been edited by TheFew (edited May 03, 2000).]
Quote Reply
Re: &get_date in modify form In reply to
Thanks for your help...I never thought I'd solve it with such small code!

I only had "Date", so just this solved the problem: if ($in{'modify_form_record'}) { $rec{'Date'} = &get_date;}

My sub get_date was fine; I believe I have the last dbman version.

Nelson