how to request a multiple select list?
Hi, I am almost new to Zope and HTML-Forms, so I have run into some difficulties. I have just a problem with a lines property of an object that should be edited. I use a form with hidden fields (for the lines property of the object there is a <input name="abc" type="hidden" values="<dtml-var user_list>">). When the user now clicks the edit button the action (let's call it action_html) should be executed. In action_html I'd like to show the user the current values (for the list it must be a multiple select) and give him/her the chance to change the properties. But how can I request the list from the previous form? I always get a list including one string (which is a list itself), like this ["['user1','user2','user3']"]. How can I simply forward the variable/value from the one form to the other? Or is it possible to request the object properties from the given id? Besides that, is there a simple solution to select the given list values in a multiple select tag? I have a workaround that looks like this: <SELECT name="newBenutzerliste:list" size="8" width="16" multiple> <dtml-in get_valid_userids> <dtml-let seqi=sequence-item> <dtml-call "REQUEST.set('sel',0)"> <dtml-in Benutzerliste> <dtml-if expr="_['seqi']==_['sequence-item']"> <OPTION selected value="<dtml-var sequence-item html_quote>"><dtml-var sequence-item></OPTION> <dtml-call "REQUEST.set('sel',1)"> </dtml-if> </dtml-in> <dtml-if sel> <dtml-else> <OPTION value="<dtml-var sequence-item html_quote>"><dtml-var sequence-item></OPTION> </dtml-if> </dtml-let> </dtml-in> </SELECT> Juergen
Juergen R. Plasser / HEXAGON writes:
.... I have just a problem with a lines property of an object that should be edited. I use a form with hidden fields (for the lines property of the object there is a <input name="abc" type="hidden" values="<dtml-var user_list>">). This makes the "value" a string of the form "['user1','user2',...]"
The easiest solution is to use a Session object (sessions are a standard part of Zope from 2.5 on. However usable only above 2.5b4) to store the list (rather than coding in the HTML form). The next easiest solution is to use one hidden variable for each list element, like that <dtml-in user_list> <input name="abc:list" type="hidden" value="&dtml-sequence-item;"> </dtml-in> Note, that your REQUEST will not contain "abc", if "user_list" happens to be empty. Otherwise, it will be the reconstituted "user_list". Dieter
participants (2)
-
Dieter Maurer -
Juergen R. Plasser / HEXAGON