Gossamer Forum
Home : Products : DBMan : Installation :

Hidden key field

Quote Reply
Hidden key field
I want to have a hidden key field, that automatically gives a new number to each new db_entry. Is that possible?
Quote Reply
Re: Hidden key field In reply to
If you're using auto-generate, set one up one field (I'll call it ID for illustration purposes). Set the field type to "numer" and set the field length to -1. Make it a required field.

Then set
$db_key = 'ID';
$db_key_track = 1;

(All of this is in the default.cfg file.)

If you're not using autogenerate, do the same things as above and then, in html.pl, use

<input type=hidden name="ID" value="$rec{'ID'}>

for the field.


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


Quote Reply
Re: Hidden key field In reply to
Hey Jp, I'm on to new fields. You mentioned that you need to add it to the html.pl. Well, I did but then I had problems with modifying. So I got paste happy.... I think I pasted too many times. Where do you recommend putting such fields? ie;<input type=hidden name="ID" value="$rec{'ID'} I don't want the user erasing other files. I just want the add part to be as painless as possible. Actually I put it every where a hidden input was ... this was basically stupid of me but I just wanted to cover all angles Smile
Quote Reply
Re: Hidden key field In reply to
Sorry. I wasn't specific about where to add it.

Take it out everywhere you have it and put it into html_record_form. You don't have to worry about it being within a table or anything, since it won't show on the form.



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





Quote Reply
Re: Hidden key field In reply to
Okay that's what I thought in the beginning but I keep getting problems where I try to stick it in.....

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);
print qq|
<table>
</table>
|;
}

So where does it go? I've tried almost all the spots, and within the table it screws up the formating, outside of the table it tells me that it can't be blank -- I have it as a necessary field. Could that be a problem?

<input type=hidden name="ID" value="$rec{'ID'}>
Quote Reply
Re: Hidden key field In reply to
Are you sure you're keeping the field name the same every time? Remember that field names are case-sensitive. If it's "ID" in the field definition, it can't be "id" or "Id" somewhere else.

If your field name is okay, it should be filling in the number automatically as part of the get_defaults subroutine.


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





Quote Reply
Re: Hidden key field In reply to
Hey JP I think I got it working. No it wasn't hairbrain'd variable declaration but I think it had to do with setting it to be a required field in the default.cfg. It didn't like it very much. Also I put it right before the closing bracket "}" at the end. hmmm, won't know for a while if this was the fix or not. thanks for your wonderful help again.