Forum OpenACS Development: Re: Preselecting option tags in template multiple
i can't reproduce the problem as described, but i see two issues in the given example: (a) there is a missing double quote after "uid" in the "select" opening tag. (b) in order to group data, one should use the "group" tag of OpenACS for best results. See the following example:
set user_id 123 template::multirow create user user_name user_id group_name template::multirow append user "Joe Dalton" 122 villain template::multirow append user "William Dalton" 123 villain template::multirow append user "Jack Dalton" 124 villain template::multirow append user "Averell Dalton" 125 villain template::multirow append user "Luky Luke" 126 cowboyhsin.adp:
<master> <form> <select id="uid" size="8" name="uid"> <multiple name="user"> <optgroup label="@user.group_name@"> <group column="group_name"> <option <if @user_id@ eq @user.user_id@>selected</if> value="@user.user_id@">@user.user_name@</option> </group> </optgroup> </multiple> </select> </form>result:
This is tested with the current version in the oacs-5-9 branch.
Hope this helps, all the best
Thanks for your detailed reply. I have switched my code over to use the group tag, which I agree is a much better way to go about it. The missing double quote was actually just a typo; it is in fact there in my code.
The output I get at the selected line becomes:
<option selected="" value="4">Jack Brown (JB-102)</option>
the ="" is generated and preventing an actual selection on the option (at least Firefox). In the screenshot you provided, does the ="" get generated in the source?
am on oacs-5-9 branch as well.
<form> <select id="uid" size="8" name="uid"> <optgroup label="villain"> <option value="122">Joe Dalton</option> <option selected value="123">William Dalton</option> <option value="124">Jack Dalton</option> <option value="125">Averell Dalton</option> </optgroup> <optgroup label="cowboy"> <option value="126">Luky Luke</option> </optgroup> </select> </form>I see no chance, how the the equals and the quotes are inserted by the template above. Are you sure, you have no plugin etc. installed, that processes the results? try to check with wget, what the server sends back.
I've checked with our admin and it seems we may have some plugins that could cause the effect. I've put in a ticket on our end. If we find that it is an internal issue, I'll update this to resolve it as a non-issue.
Thank you for your time and patience.