Created on 2008-08-26 06:33 by thomas-weber, last changed 2016-07-02 19:19 by rouilj.
|msg2582||Author: [hidden] (thomas-weber)||Date: 2008-08-26 06:33|
Filing the bug as told by Richard, http://thread.gmane.org/gmane.comp.bug-tracking.roundup.user/9083 I've changed the classic template such that "topics" is a multi-select. On such a field, if one selects items, the browser will send the corresponding item numbers. If one unselects all items, no number will be sent. This means that the last selected items stay selected. Thomas
|msg2583||Author: [hidden] (shane-green)||Date: 2008-09-12 02:42|
A nice workaround for this issue, if I understand it correctly, is to include a hidden input with the same name as the multi-select's property, and a value of "". Doing this ensures that at least an empty string will be submitted for the property on every submit. If other options are selected, this has no effect; if all options are deselected, this sets the multilink to an empty string, clearing it as desired.
|msg2584||Author: [hidden] (shane-green)||Date: 2008-09-13 01:28|
Here is a macro definition that provides the hidden input needed to allow users to unselect all options in a multi-select: <metal:macro define-macro="multiselect"> <select metal:define-slot="select" tal:define="height height | size | default;" tal:replace="structure python:context[name].menu(height=height)"> </select> <input type="hidden" value="" tal:attributes="name name;" /> </metal:macro> Here is a snippet from issue.item.html which uses the macro to create a multi-select for issue keywords: <tr tal:define="height string:5;"> <th>Topics</th> <td tal:define="name string:topics;"> <metal:macro use-macro="templates/page/macros/multiselect" /> </td> </tr> This assumes that the macro definition is placed in page.html, and sets the height of the selection box to be 5 items high. Hope that helps!
|msg2585||Author: [hidden] (thomas-weber)||Date: 2008-09-15 07:22|
Thanks to Shane for pinging me about this issue; it seems SF doesn't send me an email when this bug report is updated (although I thought it would?). Anyway, his proposal works and is good enough for me. Just a note that it should read "topic" instead of "topics" in the snippet for issue.item.html. Thanks again. Thomas
|msg3613||Author: [hidden] (ajaksu2)||Date: 2009-03-01 13:54|
I think holding Ctrl and clicking the last selected value leaves no value selected, but I still like Shane's snippets. Should I adapt it as a patch?
|msg5710||Author: [hidden] (rouilj)||Date: 2016-07-02 19:18|
Hi all: On this tracker we just have a '- no selection -' item with a value set to -1. Is selecting '- no-selection-' if you want no selection good enough? Also is the hidden field with the blank value actually supported? I am concerned that some browsers will get confused with the same name for different input types. But maybe I am giving browsers too much credit? Daniel, one thing I could see being useful is to extend menu() with the ability to generate an extra: - no selection - option or generate a hidden field. That way people don't have to mess with the tal if they call: tal:replace="structure python:context[name].menu(height=height, empty='option|hidden')"> where option adds a -1 valued '- no-selection -' option and hidden adds a the hidden field. This could be a useful patch. Thoughts? -- rouilj
|2016-07-02 19:19:23||rouilj||set||keywords: + patch|
nosy: + rouilj
messages: + msg5710
|2016-06-26 23:51:41||rouilj||set||keywords: + patch|
messages: + msg3613