Added object widget subform template
authorThierry Florac <tflorac@ulthar.net>
Sun, 26 Feb 2017 10:35:06 +0100
changeset 45 4f48cdba2e1f
parent 44 86403264c029
child 46 95e1e28acb19
Added object widget subform template
src/pyams_form/widget/configure.zcml
src/pyams_form/widget/templates/object-subform.pt
--- a/src/pyams_form/widget/configure.zcml	Tue Dec 27 15:26:31 2016 +0100
+++ b/src/pyams_form/widget/configure.zcml	Sun Feb 26 10:35:06 2017 +0100
@@ -72,6 +72,7 @@
 		widget="z3c.form.interfaces.ISelectWidget"
 		layer="pyams_form.interfaces.form.IFormLayer" />
 
+
 	<z3c:widgetTemplate
 		mode="input"
 		template="templates/orderedselect-input.pt"
@@ -84,4 +85,17 @@
 		widget="z3c.form.interfaces.IOrderedSelectWidget"
 		layer="pyams_form.interfaces.form.IFormLayer" />
 
+
+	<z3c:widgetTemplate
+		mode="input"
+		template="templates/object-subform.pt"
+		widget="z3c.form.interfaces.IObjectWidget"
+		layer="pyams_form.interfaces.form.IFormLayer" />
+
+	<z3c:widgetTemplate
+		mode="display"
+		template="templates/object-subform.pt"
+		widget="z3c.form.interfaces.IObjectWidget"
+		layer="pyams_form.interfaces.form.IFormLayer" />
+
 </configure>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_form/widget/templates/object-subform.pt	Sun Feb 26 10:35:06 2017 +0100
@@ -0,0 +1,35 @@
+<div class="object-widget" tal:attributes="class view/klass">
+	<fieldset>
+		<tal:loop repeat="widget view/subform/widgets/values">
+			<input type="hidden"
+				   tal:condition="python:widget.mode == 'hidden'"
+				   tal:replace="structure widget/render" />
+			<tal:if condition="python:widget.mode != 'hidden'">
+				<div tal:define="required python:'required-field' if widget.required and (widget.mode != 'display') else ''"
+					 tal:attributes="class string:form-group ${required}">
+					<label class="control-label col-md-3"
+						   tal:attributes="class widget/label_css_class | group/label_css_class | view/label_css_class | default">
+						<span>
+							<tal:var content="widget/label" />
+							<i class="fa fa-question-circle hint" title="Input hint"
+							   tal:define="description python:getattr(widget, 'description', widget.field.description)"
+							   tal:condition="description"
+							   tal:attributes="title description;
+											   data-ams-hint-html '<' in description;"></i>
+						</span>
+					</label>
+					<div class="col-md-9"
+						 tal:attributes="class widget/input_css_class | group/input_css_class | view/input_css_class | default">
+						<label class="input"
+							   tal:attributes="class widget/widget_css_class | default;
+											   data-ams-data extension:object_data(widget);">
+							<input tal:replace="structure python:widget.render()" />
+						</label>
+					</div>
+				</div>
+			</tal:if>
+		</tal:loop>
+		<input name="field-empty-marker" type="hidden" value="1"
+			   tal:attributes="name string:${view/name}-empty-marker" />
+	</fieldset>
+</div>