Gossamer Forum
Home : Products : DBMan : Customization :

Secondary Modify Form

Quote Reply
Secondary Modify Form
I currently have my db setup so when I list all, I can click a link next to each record to go directly to modify. I would like to have another link that goes to a separate smaller modify form with only a few fields.

I have setup a new html_record_actions with the fields to edit. I can't figure out just what to change in db.cgi to get this rolling. I know I need to add a new line to sub main maybe like this:

elsif ($in{'modify_form_actions'}) { if ($per_mod) { &html_modify_form_actions; } else { &html_unauth; } }

I just cannot figure out with sub in db.cgi to dup and change to make this work.

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
You're on the right track. I don't think you should have to do anything else in db.cgi (Carol or Lois correct me if I'm wrong). Just copy the modify part of the html.pl file and create your new subroutine with the layout you want. Keep in mind that you'll have to pass the fields you "leave out" along as hidden tags. If you don't, then when you modify the record using the "modify lite" version you'll wipe out the data in the fields that don't show on the page.

<INPUT TYPE="hidden" NAME="field that doesn't show" VALUE="rec{'field that doesn't show'}">

Use this to keep from losing data in the fields that don't show your modified modify page.
Quote Reply
Re: [Watts] Secondary Modify Form In reply to
Thanks for that! I had no idea I would be screwing up my db by not adding those lines!!!

So here is what I did.

I added a line to db.cgi:

elsif ($in{'modify_form_action'}) { if ($per_mod) { &html_modify_form_action; } else { &html_unauth; } }

I added to the html.pl file a sub html_record_action and a sub html_modify_form_action. Within the sub html_modify_form_action I changed the following 3 lines:

if (($numhits == 1) and !$in{'nh'}) { $in{'modify'} = $hits[$db_key_pos]; &html_modify_form_action(); return; }
<TD><INPUT TYPE=RADIO NAME="modify" VALUE="$tmp{$db_key}"> |; &html_record_action (%tmp);
<P><center><input type="SUBMIT" name="modify_form_action" value="Modify Record"> <INPUT TYPE="RESET" VALUE="Reset Form"></center></p>

All that happens is it hangs. Interesting since usually when you screw up you get the error page.

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
Here's what I would do:

Copy the whole sub html_modify_form_record and paste it into the html.pl file.

Change the name of the new subroutine to html_modify_form_action.

Copy all of the fields from sub html_record_form.

Go back to the new subroutine and replace the line

Code:

|; &html_record_form (%rec); print qq|


with the fields that you copied.

Replace the fields that you don't want to appear on the modify form with hidden fields.

That's all you should have to do.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
I guess you can tell, I'm back using the script after a while. Anyway, that worked EXCEPT . . .

I have an "A" after each record in List All, that is a link to:
Code:
<A HREF="$db_script_link_url&modify_form_action=Search&fileno=$rec{'fileno'}">

I have put all the hiddens in the sub html_action_form. Now when I click the "A" I get a the correct modify form with no data associated. The options in the html link are missing the fileno:
Code:
&modify_form_action=Search&fileno=

If I copy the potential link, the fileno is there, if I click it, it disappears. Why is it not being passed?

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
Quote:
I have an "A" after each record in List All,

I don't understand. Is this an "A" that you have programmed, or an "A" that appears where you don't want it to? If it's something that you programmed, how did you program it and where?


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
Forgive me. The A is just the text between the <a href>A</a>.

And, something I did now made the search option show up. This is what is after the URL:
Code:
db=default&uid=kcgbjj.113851498343643&modify_form_action=1&fileno=2105FAYMONT

The problem is that the search page shows, but with no data whatsoever, as if I am editing a blank record.

Chris
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
Sorry. The A is meaningless. It is just the text that is between the <a href=""> and </a>.

The main point is that the link should bring me to the modify page lite as it does, but no data is passed through.

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
How are you generating the URL? What is the code that makes it? I'm trying to figure out what you are using so I can figure out what's wrong with it.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
In Reply To:
Here's what I would do:

I did exactly what you asked in your previous post, which did successfully allow me to pull up the proper form with the following URL:
Code:
/db/db.cgi?db=default&uid=xxxx&modify_form_action=1&fileno=2105FAYMONT

The code for the form includes a bunch of <input hidden> statements then a table that starts with the static text of an address:
Code:
<TABLE WIDTH="95%" BORDER="0" ALIGN="CENTER" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD COLSPAN="4"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD COLSPAN="4" ALIGN="CENTER" VALIGN="TOP" NOWRAP>$rec{'subjectstreet'},
$rec{'subjectcity'}&nbsp;&nbsp; $rec{'subjectzip'}</TD>
</TR>

I'm guessing I still have to have an <input hidden> for subjectstreet, subjectcity, and subjectzip?? Is that true?

The reason I think that no data is being passed is that the only thing on the top of the page, after the successful execution of sub html_header, is a comma . . . the comma that should show between subject street and subject city.

Interesting tidbit, when I copy the exact original data from sub html_modify_form_record and sub html_record_form into my new subs, there is still no data passed. The only other thing edited was the db.cgi by adding the following line:
Code:
elsif ($in{'modify_form_action'}) { if ($per_mod) { &html_modify_form_action; } else { &html_unauth; } }

Does that help?

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
Quote:
I'm guessing I still have to have an <input hidden> for subjectstreet, subjectcity, and subjectzip?? Is that true?

Yes. I think so. You need to have input fields, hidden or visible, on your form for every field in your database. If you don't, you will lose the data that is in those fields when you send the modified data to be written into your file.

Quote:

Does that help?

Not really. :-) I need the code that creates the A url that you click on that doesn't work.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
<A HREF="$db_script_link_url&modify_form_action=1&fileno=$rec{'fileno'}"><B>A</B><A>

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
Aha!

Try

Code:
<A HREF="$db_script_link_url&modify_form_action=1&modify=$rec{'fileno'}"><B>A</B><A>


(Assuming that 'fileno' is your db_key field.)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
Tried that, both with fileno (not my db_key) and ID (my db_key). Interesting, when I use fileno, the URL looks clean but when I use ID I get an URL like this:
Code:
db.cgi?db=default&uid=xxxx&modify_form_action=1&modify=<B>53</B><B></B>

Where the heck are the <b>'s coming from?

So I changed my db_key to fileno (and to not track as fileno is never sequential) and if I use ID in the URL, no <b>'s, but with fileno in the URL like you suggested, I get:
Code:
db.cgi?db=default&uid=xxxx&modify_form_action=1&modify=<B>2105FAYMONT</B><B></B>

So I only get the <b>'s when I use the db_key in the URL. I can't figure out where the <b>'s are coming from for anything.

Chris
Quote Reply
Re: [jnjhost] Secondary Modify Form In reply to
In sub html_record, after
Code:
my (%rec) = @_;


add
Code:
$rec{$db_key} =~ s/<.?B>//g;


(I put this in the FAQ on this site several times because people have problems with it all the time. Someone has deleted it every time I've put it in, so I quit putting it in. This is caused by the setting in the .cfg file which bolds search results. Often it causes a lot of problems.)

And, in your URL code use
Code:
<A HREF="$db_script_link_url&modify_form_action=1&modify=$rec{$db_key}"><B>A</B><A>


It doesn't really matter which field is your db_key field, as long as no two records have the same value. But you must use the db_key field when you are going to modify a record. That's how the script knows which record to modify.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
First of all, you may notice I'm logged in as another user. JNJHost is a company I sold years ago. Jason just reset my user kcgbjc for me so I could log in as that. Kcgbjc is my families initials. I know, TMI.

That worked, thank you. I had to do a couple of mods to the href's tho so I'll post them for your comment. They work however I don't know why the same format doesn't work for each. See below for what is working for me, comment if you wish:
Code:
$rec{$db_key} =~ s/<.?B>//g;
<A HREF="$db_script_link_url&modify_form=1&fileno=$rec{'fileno'}"><B>M</B><A>
<A HREF="$db_script_link_url&modify_form_action=1&modify=$rec{'ID'}"><B>A</B><A>

Chris

Last edited by:

kcgbjc: Jan 29, 2006, 7:58 PM
Quote Reply
Re: [kcgbjc] Secondary Modify Form In reply to
Quote:
I know, TMI.


:-)

Let me see if I can explain what's going on with your links, especially the one that uses the "modify_form" language.

Let's say you went through the normal modify routine. You would click the link in the footer that says "Modify," which would take you to a search form. You would fill in your search criteria and click the button. The script would do a search for records that fit that criteria. If there were more than one record returned from the search, you would get a list of the records, with radio buttons to the side so that you could select which one you wanted to modify. After you click the button at the bottom of the form, the script then displays the form with the record so that you can modify it.

If the search returns only one record, the form with the radio buttons is skipped and the script automatically switches to the form with the record, pulling the $db_key value from the record and assigning it to the $in{'modify'} variable.

Your link with the "modify_form" language does the same thing that the modify search form does. You set a criterion for a search, only one record is returned, so the script skips the form with the radio button and sends you to the modify form. If your search criterion were to return two or more records, you would get the form with the radio buttons so you could choose which one you want to use. Your results would be identical if your "M" link was as follows:

<A HREF="$db_script_link_url&modify_form_record=1&modify=$rec{$db_key}"><B>M</B><A>

I think it would be better to use the format above. It would use fewer of the server's resources, for one thing. The way you have it, the script has to do two searches, the first one of which is unnecessary.

The reason I use the $rec{$db_key} format instead of the field name is that you won't have to make any changes to your script if you change which field is the $db_key field. Also, with the code I gave you, the bolding tags are only taken out of the $db_key field. If your original list of records uses some other search criteria, you might have the same bolding problem that you had before.

If it was my database, the links would look like:

<A HREF="$db_script_link_url&modify_form_record=1&modify=$rec{$db_key}"><B>M</B><A>
<A HREF="$db_script_link_url&modify_form_action=1&modify=$rec{$db_key}"><B>A</B><A>


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Jan 30, 2006, 9:32 PM
Quote Reply
Re: [JPDeni] Secondary Modify Form In reply to
Absolutely clear. My code is exactly as you suggested and working like a star! You are awesome!

Chris
Quote Reply
Re: [kcgbjc] Secondary Modify Form In reply to
:-) I'm glad I could help.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [kcgbjc] Secondary Modify Form In reply to
One thing you need to fix still is the ending </A> code.

You have:

<A HREF="$db_script_link_url&modify_form_record=1&modify=$rec{$db_key}"><B>M</B><A>
<A HREF="$db_script_link_url&modify_form_action=1&modify=$rec{$db_key}"><B>A</B><A>

which should be:

<A HREF="$db_script_link_url&modify_form_record=1&modify=$rec{$db_key}"><B>M</B></A>
<A HREF="$db_script_link_url&modify_form_action=1&modify=$rec{$db_key}"><B>A</B></A>

or you will have problems :)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Secondary Modify Form In reply to
In Reply To:
One thing you need to fix still is the ending </A> code.

Thank you for noticing my stupid mistake. Interesting that I didn't run into any problems with that one!

Chris