Updated radio and checkbox widget templates
authorThierry Florac <tflorac@ulthar.net>
Tue, 17 Sep 2019 11:58:12 +0200
changeset 187 cc168a57df8d
parent 186 ddd454de3d32
child 188 a85a46a42e72
Updated radio and checkbox widget templates
src/pyams_form/widget/templates/checkbox-display.pt
src/pyams_form/widget/templates/checkbox-input.pt
src/pyams_form/widget/templates/html-input.pt
src/pyams_form/widget/templates/radio-display.pt
src/pyams_form/widget/templates/radio-input.pt
--- a/src/pyams_form/widget/templates/checkbox-display.pt	Tue Sep 17 11:56:41 2019 +0200
+++ b/src/pyams_form/widget/templates/checkbox-display.pt	Tue Sep 17 11:58:12 2019 +0200
@@ -1,18 +1,16 @@
 <i18n:var i18n:domain="pyams_form"
-	tal:define="translate python:request.localizer.translate">
+		  tal:define="translate python:request.localizer.translate">
+	<input name="field-empty-marker" type="hidden" value="1"
+			tal:attributes="name string:${view/name}-empty-marker" />
 	<tal:loop define="items view/items"
 			  repeat="item items">
 		<label class="checkbox">
-			<input name="field-empty-marker" type="hidden" value="1"
-					tal:attributes="name string:${view/name}-empty-marker" />
-			<input type="checkbox" id="" name="" class="" alt="" title=""
-				   tabindex="" accesskey="" value="" disabled
-				   checked="checked"
-				tal:condition="item/checked"
+			<input type="checkbox" disabled
 				tal:attributes="id item/id;
 								name item/name;
 								class view/klass;
 								value item/value;
+								checked python:'checked' if item['checked'] else None;
 								style view/style;
 								title view/title;
 								lang view/lang;
@@ -32,36 +30,9 @@
 								onchange view/onchange;
 								alt view/alt;
 								accesskey view/accesskey;
-								onselect view/onselect" />
-			<input id="" name="" class="" alt="" title="" tabindex=""
-				   accesskey="" value="" disabled
-				   type="checkbox"
-				tal:condition="not:item/checked"
-				tal:attributes="id item/id;
-								name item/name;
-								class view/klass;
-								value item/value;
-								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;
-								alt view/alt;
-								accesskey view/accesskey;
-								onselect view/onselect" />
-			<i></i><span tal:replace="python:translate(item['label'])" i18n:translate="">Label</span>
+								onselect view/onselect;
+								data-ams-data tales:object_data(view);" />
+			<i></i><span tal:replace="python:translate(item['label'])">Label</span>
 		</label>
 	</tal:loop>
-</i18n:var>
+</i18n:var>
\ No newline at end of file
--- a/src/pyams_form/widget/templates/checkbox-input.pt	Tue Sep 17 11:56:41 2019 +0200
+++ b/src/pyams_form/widget/templates/checkbox-input.pt	Tue Sep 17 11:58:12 2019 +0200
@@ -1,17 +1,16 @@
-<i18n:var i18n:domain="pyams_form">
+<i18n:var i18n:domain="pyams_form"
+		  tal:define="translate python:request.localizer.translate">
 	<input name="field-empty-marker" type="hidden" value="1"
 			tal:attributes="name string:${view/name}-empty-marker" />
 	<tal:loop define="items view/items"
 			  repeat="item items">
 		<label class="checkbox">
-			<input type="checkbox" id="" name="" class="" alt="" title=""
-				   tabindex="" disabled="" readonly="" accesskey="" value=""
-				   checked="checked"
-				tal:condition="item/checked"
+			<input type="checkbox"
 				tal:attributes="id item/id;
 								name item/name;
 								class view/klass;
 								value item/value;
+								checked python:'checked' if item['checked'] else None;
 								style view/style;
 								title view/title;
 								lang view/lang;
@@ -25,46 +24,15 @@
 								onkeypress view/onkeypress;
 								onkeydown view/onkeydown;
 								onkeyup view/onkeyup;
-								disabled view/disabled;
 								tabindex view/tabindex;
 								onfocus view/onfocus;
 								onblur view/onblur;
 								onchange view/onchange;
-								readonly view/readonly;
 								alt view/alt;
 								accesskey view/accesskey;
-								onselect view/onselect" />
-			<input id="" name="" class="" alt="" title="" tabindex=""
-				   disabled="" readonly="" accesskey="" value=""
-				   type="checkbox"
-				tal:condition="not:item/checked"
-				tal:attributes="id item/id;
-								name item/name;
-								class view/klass;
-								value item/value;
-								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;
-								disabled view/disabled;
-								tabindex view/tabindex;
-								onfocus view/onfocus;
-								onblur view/onblur;
-								onchange view/onchange;
-								readonly view/readonly;
-								alt view/alt;
-								accesskey view/accesskey;
-								onselect view/onselect" />
-			<i></i><span tal:replace="python:request.localizer.translate(item['label'])">Label</span>
+								onselect view/onselect;
+								data-ams-data tales:object_data(view);" />
+			<i></i><span tal:replace="python:translate(item['label'])">Label</span>
 		</label>
 	</tal:loop>
-</i18n:var>
+</i18n:var>
\ No newline at end of file
--- a/src/pyams_form/widget/templates/html-input.pt	Tue Sep 17 11:56:41 2019 +0200
+++ b/src/pyams_form/widget/templates/html-input.pt	Tue Sep 17 11:58:12 2019 +0200
@@ -1,6 +1,5 @@
 <textarea id="" name="" class="" cols="" rows=""
 		  tabindex="" disabled="" readonly="" accesskey=""
-		  i18n:domain=""
 		  tal:attributes="id view/id;
 						  name view/name;
 						  class string:${view/klass} tinymce;
--- a/src/pyams_form/widget/templates/radio-display.pt	Tue Sep 17 11:56:41 2019 +0200
+++ b/src/pyams_form/widget/templates/radio-display.pt	Tue Sep 17 11:58:12 2019 +0200
@@ -1,18 +1,34 @@
-<input type="text" readonly i18n:domain="pyams_form"
-	   tal:define="translate python:request.localizer.translate"
-	   tal:attributes="id view/id;
-					   class string:${view/klass} border-0;
-					   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;
-					   value python:', '.join((translate(value) for value in view.displayValue))" />
\ No newline at end of file
+<div class="inline-group" i18n:domain="pyams_form"
+	 tal:define="translate python:request.localizer.translate">
+	<label class="radio"
+		   tal:repeat="item view/items">
+		<input type="radio" disabled
+			   tal:attributes="id item/id;
+								name item/name;
+								class view/klass;
+								value item/value;
+								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;
+								readonly view/readonly;
+								alt view/alt;
+								accesskey view/accesskey;
+								onselect view/onselect;
+								checked python:'checked' if item['checked'] else None;" />
+		<i></i><span tal:replace="item/label" i18n:translate="">Label</span>
+	</label>
+</div>
\ No newline at end of file
--- a/src/pyams_form/widget/templates/radio-input.pt	Tue Sep 17 11:56:41 2019 +0200
+++ b/src/pyams_form/widget/templates/radio-input.pt	Tue Sep 17 11:58:12 2019 +0200
@@ -1,4 +1,5 @@
-<div class="inline-group" i18n:domain="pyams_form">
+<div class="inline-group" i18n:domain="pyams_form"
+	 tal:define="translate python:request.localizer.translate">
 	<label class="radio"
 		   tal:repeat="item view/items">
 		<input type="radio"
@@ -33,4 +34,4 @@
 								data-ams-data tales:object_data(view);" />
 		<i></i><span tal:replace="item/label" i18n:translate="">Label</span>
 	</label>
-</div>
+</div>
\ No newline at end of file