Added notice before and after widgets, and added CSS class to form groups
authorThierry Florac <thierry.florac@onf.fr>
Fri, 26 Jan 2018 17:24:47 +0100
changeset 77 e9c0e9b18694
parent 76 81ec137eb851
child 78 1e9abe10474b
Added notice before and after widgets, and added CSS class to form groups
src/pyams_form/templates/form.pt
src/pyams_form/templates/inner-form.pt
src/pyams_form/templates/widget-form.pt
--- a/src/pyams_form/templates/form.pt	Mon Dec 11 15:27:00 2017 +0100
+++ b/src/pyams_form/templates/form.pt	Fri Jan 26 17:24:47 2018 +0100
@@ -88,8 +88,8 @@
 									   tal:condition="widget.mode == 'hidden'"
 									   tal:replace="structure widget.render()" />
 								<tal:if condition="widget.mode != 'hidden'">
-									<div tal:define="required 'required-field' if widget.required and (widget.mode != 'display') else ''"
-										 tal:attributes="class string:form-group ${required}">
+									<div tal:define="required 'required-field' if widget.required and widget.label and (widget.mode != 'display') else ''"
+										 tal:attributes="class string:${widget.group_css_class | group.group_css_class | view.group_css_class | 'form-group'} ${required}">
 										<label tal:attributes="class widget.label_css_class | group.label_css_class | view.label_css_class">
 											<span>
 												<tal:var content="widget.label" />
@@ -105,7 +105,13 @@
 												   tal:attributes="class widget.widget_css_class | default;
 																   data-ams-data extension:object_data(widget);
 																   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
+												<div tal:define="notice widget.before_widget_notice | nothing"
+													 tal:condition="notice"
+													 tal:content="structure notice">Notice</div>
 												<input tal:replace="structure widget.render()" />
+												<div tal:define="notice widget.after_widget_notice | nothing"
+													 tal:condition="notice"
+													 tal:content="structure notice">Notice</div>
 											</label>
 										</div>
 									</div>
--- a/src/pyams_form/templates/inner-form.pt	Mon Dec 11 15:27:00 2017 +0100
+++ b/src/pyams_form/templates/inner-form.pt	Fri Jan 26 17:24:47 2018 +0100
@@ -73,8 +73,8 @@
 							   tal:condition="widget.mode == 'hidden'"
 							   tal:replace="structure widget.render()" />
 						<tal:if condition="widget.mode != 'hidden'">
-							<div tal:define="required 'required-field' if widget.required and (widget.mode != 'display') else ''"
-								 tal:attributes="class string:form-group ${required}">
+							<div tal:define="required 'required-field' if widget.required and widget.label and (widget.mode != 'display') else ''"
+								 tal:attributes="class string:${widget.group_css_class | group.group_css_class | view.group_css_class | 'form-group'} ${required}">
 								<label tal:attributes="class widget.label_css_class | group.label_css_class | view.label_css_class">
 									<span>
 										<tal:var content="widget.label" />
@@ -89,7 +89,13 @@
 									<label class="input"
 										   tal:attributes="class widget.widget_css_class | default;
 														   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
+										<div tal:define="notice widget.before_widget_notice | nothing"
+											 tal:condition="notice"
+											 tal:content="structure notice">Notice</div>
 										<input tal:replace="structure widget.render()" />
+										<div tal:define="notice widget.after_widget_notice | nothing"
+											 tal:condition="notice"
+											 tal:content="structure notice">Notice</div>
 									</label>
 								</div>
 							</div>
--- a/src/pyams_form/templates/widget-form.pt	Mon Dec 11 15:27:00 2017 +0100
+++ b/src/pyams_form/templates/widget-form.pt	Fri Jan 26 17:24:47 2018 +0100
@@ -67,8 +67,8 @@
 									   tal:condition="widget.mode == 'hidden'"
 									   tal:replace="structure widget.render()" />
 								<tal:if condition="widget.mode != 'hidden'">
-									<div tal:define="required 'required-field' if widget.required and (widget.mode != 'display') else ''"
-										 tal:attributes="class string:form-group ${required}">
+									<div tal:define="required 'required-field' if widget.required and widget.label and (widget.mode != 'display') else ''"
+										 tal:attributes="class string:${widget.group_css_class | group.group_css_class | view.group_css_class | 'form-group'} ${required}">
 										<label tal:attributes="class widget.label_css_class | group.label_css_class | view.label_css_class">
 											<span>
 												<tal:var content="widget.label" />
@@ -83,7 +83,13 @@
 											<label class="input"
 												   tal:attributes="class widget.widget_css_class | default;
 																   data-ams-form-validator view.get_widget_callback(widget.field.getName())">
+												<div tal:define="notice widget.before_widget_notice | nothing"
+													 tal:condition="notice"
+													 tal:content="structure notice">Notice</div>
 												<input tal:replace="structure widget.render()" />
+												<div tal:define="notice widget.after_widget_notice | nothing"
+													 tal:condition="notice"
+													 tal:content="structure notice">Notice</div>
 											</label>
 										</div>
 									</div>