Hi, I am trying to have one of my forms provide the user the ability to choose what form to select next. I have done something similar to this in a previous form. In the first form I provide a pull down menu to let them select (Report vs. Input forms). I define the menu_type variable and submit the form. The next form, the user is still making some choices so this is where I set the variable globally (<dtml-call "REQUEST.SESSION.set('menu_type', menu_type)"> ). The user is making their final selection in this form and in the form action field I use this statement (action=<dtml-var expr="REQUEST.SESSION['menu_type']">) and this works. The user is in the form they selected and they are happy. I am working on some input forms now. The first form, the user will input a part number. The next form will display the title of the part number and any actions relating to this part number (RMAs, etc). At this point, if the user can continue to identify a problem with this part and fill in the header info (customer, address, etc.). What the user wants is the ability to add line item information about each serial number relating to the part. This is my problem. I can let them add one disposition. I tried the following: I made the <input type="hidden" name="menu_type"> on the first form. The next form the user can fill out the form and the "form action" will call a decision form. Also, I global define this variable <dtml-call "REQUEST.SESSION.set('menu_type', menu_type)"> The form is as follows: <form name="form1" method="post" action=<dtml-var expr="REQUEST.SESSION['menu_type']">> <select name="<dtml-var expr="REQUEST.SESSION['menu_type']"> "> <option value="update_nonc_partb">Add another disposition</option> <option value="update_nonc_partb_info">Save</option> </select> <dtml-var expr="REQUEST.SESSION['menu_type']"> <input type="submit" name="Submit" value="Submit"> </form> I have tried different variation but I will get a keyerror or a global error. Any pointers would be great. Sorry for the winded message but I thought some background would help. Thanks in advance. Larry McDonnell Proton Energy Systems 10 Technology Drive Wallingford, CT 06492 (203) 678-2181 Email:lmcdonnell@protonenergy.com www.protonenergy.com
Hi Larry, [snip description] ... if I understand Your question right, You use the Session to store a variable 'menu_type', which will determine the object the form submit is send to. Your problem is:
I have tried different variation but I will get a keyerror or a global error. Any pointers would be great.
Hm, maybe post one variation (preferably reduced to a minimal version) and one error message -- this would help spotting the problem, I guess. You may alternatively set the action for the form to a Python script, which investigates the session data and then dispatches to the "right" DTML Method displaying the selected form. If you do so, You could do better checks in the script, if the session variable is set at all or do other logic. For example You could do: if not request.SESSION.has_key('menu_type'): # hm, something is wrong ... handle error, e.g. raise IndexError, 'session has no key "menu_type"' else: form_renderer = getattr(context, menu_type) return form_renderer() This may give You more freedom to add debugging hooks to find the problem Yourself. Cheers, Clemens
participants (2)
-
Clemens Robbenhaar -
McDonnell, Larry