Gossamer Forum
Home : Products : DBMan : Customization :

unchangeable field

Quote Reply
unchangeable field
I am using an ID number of which DBman keeps track for me, and I want it visible to the user who adds something, but I don't want people to be able to change it

Any ideas?

P.S. i am using auto_generate so I can't just change the html, at least not any way I know how



Thanks! Mike
Quote Reply
Re: [mabel] unchangeable field In reply to
in db.cgi look for the subroutine

build_html_record_form and insert the following bit

Code:
elsif ($db_form_len{$field} == -3) {
$output = qq~<tr><input type=hidden name="$field" value="$rec{$field}">
<td align=right valign=top width=20%>
<$font>$field:</font></td>
<td width=80%>$rec{$field}</td></tr>~;}

right after the part about

Code:
elsif ($db_form_len{$field} == -1) {
$output = qq~<input type=hidden name="$field" value="$rec{$field}">$output~; }

Then in default.cfg change the "form length" to -3. I sorta checked it out and it seems to work. Try it and if it doesn't work undo the above instructions.

Good Luck!

Ps: I was getting some weird formatting but I think it is left over from an earlier hack.
Quote Reply
Re: [Watts] unchangeable field In reply to
Okay, it works. The only problem is that you can't search for ID# (for modify search or view search). Solve one problem, create two more!

Hmm... will have to add in some more if/thens.
Quote Reply
Re: [Watts] unchangeable field In reply to
that's cool..thanks
the only downside is you can't search by it now...
Quote Reply
Re: [mabel] unchangeable field In reply to
Okay replace it with this and you can...

Code:
elsif ($db_form_len{$field} == -3) {
if (($in{'view_search'} == "1") || ($in{'modify_search'} == "1")) {
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><input type=text name="$field" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>~;
}
else {
$output . = qq~<tr><td align=right valign=top width=20%><input type=hidden name="$field" value="$rec{$field}"><$font>$field:</font></td>
<td width=80%>$rec{$field}</td></tr>~;
}
}

Last edited by:

Watts: Jul 10, 2002, 3:54 PM
Quote Reply
Re: [Watts] unchangeable field In reply to
thanks a million.

mike

i don't understand how the formatting changed, do you?
Quote Reply
Re: [mabel] unchangeable field In reply to
Did it screw up your table? If so swap the the following part around...

change this:
<tr><input type=hidden name="$field" value="$rec{$field}"><td align=right valign=top width=20%>

to this:
<tr><td align=right valign=top width=20%><input type=hidden name="$field" value="$rec{$field}">

You're basically sticking the hidden field inside the table row (<TR><TD>stuff instead of <TR>stuff<TD>)

See if that works.

If your formatting is okay, then ignore this.
Quote Reply
Re: [Watts] unchangeable field In reply to
no, i found the problem
$output .= qq~<tr><td align=right valign=top width=20%>
...s
it was missing a period in the second output. check your code above

Thanks for all your help!
Quote Reply
Re: [mabel] unchangeable field In reply to
Wow! Isn't that funny? I was just making the changes to the above code (in red - including the period).

Great! Hope it works for you!