Added custom widget template for display-mode ordered list
authorThierry Florac <thierry.florac@onf.fr>
Tue, 27 Dec 2016 15:26:31 +0100
changeset 44 86403264c029
parent 43 acb7d0b6a22b
child 45 4f48cdba2e1f
Added custom widget template for display-mode ordered list
src/pyams_form/widget/configure.zcml
src/pyams_form/widget/templates/orderedselect-display.pt
--- a/src/pyams_form/widget/configure.zcml	Tue Nov 15 09:56:10 2016 +0100
+++ b/src/pyams_form/widget/configure.zcml	Tue Dec 27 15:26:31 2016 +0100
@@ -78,4 +78,10 @@
 		widget="z3c.form.interfaces.IOrderedSelectWidget"
 		layer="pyams_form.interfaces.form.IFormLayer" />
 
+	<z3c:widgetTemplate
+		mode="display"
+		template="templates/orderedselect-display.pt"
+		widget="z3c.form.interfaces.IOrderedSelectWidget"
+		layer="pyams_form.interfaces.form.IFormLayer" />
+
 </configure>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_form/widget/templates/orderedselect-display.pt	Tue Dec 27 15:26:31 2016 +0100
@@ -0,0 +1,38 @@
+<label class="input"
+	   tal:omit-tag="view/required" i18n:domain="pyams_security">
+	<div class="select2-parent"
+		 tal:omit-tag="view/required">
+		<select class="select2 ordered" disabled="disabled"
+				tal:attributes="id view/id;
+								name string:${view/name}:list;
+								class string:${view/klass} select2 ordered;
+								style view/style;
+								title view/title;
+								lang view/lang;
+								onclick view/onclick;
+								ondblclick view/ondblclick;
+								onmousedown view/onmousedown;
+								onmouseup view/onmouseup;
+								onmouseover view/onmouseover;
+								onmousemove view/onmousemove;
+								onmouseout view/onmouseout;
+								onkeypress view/onkeypress;
+								onkeydown view/onkeydown;
+								onkeyup view/onkeyup;
+								tabindex view/tabindex;
+								onfocus view/onfocus;
+								onblur view/onblur;
+								onchange view/onchange;
+								multiple view/multiple;
+								size view/size">
+			<option tal:repeat="entry view/selectedItems"
+					tal:attributes="value entry/value;
+									selected python:entry['value'] in view.value;"
+					tal:content="entry/content"></option>
+			<option tal:repeat="entry view/notselectedItems"
+					tal:attributes="value entry/value;
+									selected python:entry['value'] in view.value;"
+					tal:content="entry/content"></option>
+		</select>
+	</div>
+</label>