RE: [Zope] lists, not strings in database
That makes sense. So, what I would like is either a comma sepparated list in the column, or space separated. aperson bperson cperson The end result is this... I would like to create an array, at a later time, based on this record, to generate a view in html of the selected items and also to create a mailto: link from these. These are usernames on our network, so I can simply add the '@domain.com' and I am set. My thought was this... (simplified, of course) <dtml-in sqlMethod> <dtml-var Column1> <dtml-var Column2> <dtml-var Column3> <dtml-in PeopleInvolved> <a href="mailto:<dtml-var sequence-item>@domain.com">Email: <dtml-var sequence-item></a> </dtml-in> </dtml-in> Storing the multiple values in this way should work, correct? But, how do I get them to store that way? Greg -----Original Message----- From: Thomas B. Passin [mailto:tpassin@mitretek.org] Sent: Tuesday, September 03, 2002 12:40 PM To: zope@zope.org Subject: Re: [Zope] lists, not strings in database [Greg Fischer] [[ I need help with saving a select box value. When multiple items are selected in my form, and then inserted into a SQL server, it is saved as a string that looks like a list. I have tried to specify the data type in name value, none of which change the stored value in the database. ]] First you have to decide what should be stored in the database when the form has multiple selections. Then you have to decide how to insert that into the database. Then we can talk about how to make Zope do that, if it has not become clear by then. Cheers, Tom P _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
[Greg Fischer] [[ That makes sense. So, what I would like is either a comma sepparated list in the column, or space separated. aperson bperson cperson ]] OK, easy enough. If "multiples" is a list of strings, you can get a comma-separated string for it like this: <dtml-var "_.string.join(multiples,',')"> You can use any separator, not just ",". You could store this string in the database. When you want to loop through all the names, you can create a list from the string like this: "_.string.split(csv_string,',')" You can use this list with dtml-in, as in <dtml-in "_.string.split(csv_string,',')">...</dtml-in> The only point you still need to handle is to make sure that your html form always returns a list (otherwise you have to check it before you feed it to a dtml-in statement). You can make this happen by adding ":list" to the name of the input element: <select name='person:list'>...</select> Cheers, Tom P
participants (2)
-
Greg Fischer -
Thomas B. Passin