Added display form template
authorThierry Florac <thierry.florac@onf.fr>
Tue, 17 Nov 2015 12:03:34 +0100
changeset 139 ccaaf3f4e564
parent 138 bb3455b44178
child 140 aa78e9eb61ad
Added display form template
src/ztfy/myams/configure.zcml
src/ztfy/myams/templates/forms/form-display.pt
--- a/src/ztfy/myams/configure.zcml	Tue Nov 17 12:02:23 2015 +0100
+++ b/src/ztfy/myams/configure.zcml	Tue Nov 17 12:03:34 2015 +0100
@@ -144,11 +144,16 @@
 
 	<!-- Forms layouts, views and templates -->
 	<z3c:template
-		for="z3c.form.interfaces.IInputForm"
+		for="z3c.form.interfaces.IForm"
 		template="templates/forms/form.pt"
 		layer=".layer.MyAMSLayer" />
 
 	<z3c:template
+		for="z3c.form.interfaces.IDisplayForm"
+		template="templates/forms/form-display.pt"
+		layer=".layer.MyAMSLayer" />
+
+	<z3c:template
 		for=".interfaces.IInnerForm"
 		template="templates/forms/inner-form.pt"
 		layer=".layer.MyAMSLayer" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ztfy/myams/templates/forms/form-display.pt	Tue Nov 17 12:03:34 2015 +0100
@@ -0,0 +1,129 @@
+<div class="modal-content">
+	<div class="modal-header">
+		<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
+				tal:condition="view/isDialog">
+			<i class="fa fa-fw fa-times-circle"></i>
+		</button>
+		<h3 class="modal-title"
+			tal:define="config context/myams:configuration;">
+			<img tal:condition="config/logo"
+				 tal:attributes="src string:${config/logo/@@absolute_url}/++display++w200.png;
+								 alt config/logo_title;">
+			<span class="title" tal:content="view/title | config/title">Title</span>
+		</h3>
+	</div>
+	<div class="modal-body no-padding">
+		<div tal:replace="structure provider:form_prefix">Form prefix</div>
+		<form method="post"
+			  data-async
+			  tal:attributes="id view/id;
+							  name view/name;
+							  method view/method;
+							  enctype view/enctype;
+							  acceptCharset view/acceptCharset;
+							  accept view/accept;
+							  autocomplete view/autocomplete;
+							  class view/css_class;
+							  data-ams-data view/myams:data;
+							  data-ams-form-options view/getFormOptions;">
+			<div class="modal-viewport">
+				<fieldset>
+					<legend tal:define="legend view/legend | nothing"
+							tal:condition="legend"
+							tal:content="legend">Legend</legend>
+					<div class="widgets-prefix"
+						 tal:define="prefix provider:widgets_prefix"
+						 tal:condition="prefix"
+						 tal:content="structure prefix">Widgets prefix</div>
+					<tal:loop repeat="group view/groups">
+						<fieldset tal:define="legend group/legend"
+								  tal:omit-tag="not:legend">
+							<tal:if condition="group/checkbox_switch">
+								<legend tal:condition="legend"
+										tal:content="legend"
+										tal:attributes="class group/css_class;
+														data-ams-checker-fieldname group/checker_field/getName;
+														data-ams-checker-state group/checker_state;">Legend</legend>
+							</tal:if>
+							<tal:if condition="not:group/checkbox_switch">
+								<legend tal:condition="legend"
+										tal:content="legend"
+										tal:attributes="class group/css_class;
+														data-ams-switcher-state group/switcher_state;">Legend</legend>
+							</tal:if>
+							<tal:var define="help group/help" condition="help">
+								<div class=""
+									 tal:define="i18n_help help/i18n:translate"
+									 tal:content="structure i18n_help/html:text"></div>
+							</tal:var>
+							<tal:loop repeat="widget group/visible_widgets">
+								<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 tal:attributes="class view/label_css_class">
+											<span>
+												<tal:var content="widget/label" />
+												<i class="fa fa-question-circle hint" title="Input hint"
+												   tal:define="description widget/field/description"
+												   tal:condition="description"
+												   tal:attributes="title description;
+																   data-ams-hint-html python:'<' in description;"></i>
+											</span>
+										</label>
+										<div tal:attributes="class view/input_css_class">
+											<label class="input"
+												   tal:attributes="data-ams-data widget/myams:data;
+																   data-ams-form-validator python:view.getWidgetCallback(widget.field.getName())">
+												<input tal:replace="structure widget/render" />
+											</label>
+										</div>
+									</div>
+								</tal:if>
+							</tal:loop>
+						</fieldset>
+					</tal:loop>
+					<div class="widgets-suffix"
+						 tal:define="suffix provider:widgets_suffix"
+						 tal:condition="suffix"
+						 tal:content="structure suffix">Widgets suffix</div>
+					<div class="subforms"
+						 tal:condition="view/subforms">
+						<fieldset tal:define="title view/subforms_legend"
+								  tal:omit-tag="not:title">
+							<legend tal:condition="title" tal:content="title" i18n:translate="">Title</legend>
+							<tal:loop repeat="subform view/subforms">
+								<tal:var replace="structure subform/render" />
+							</tal:loop>
+						</fieldset>
+					</div>
+					<div class="tabforms"
+						 tal:condition="view/tabforms">
+						<ul class="nav nav-tabs">
+							<li tal:repeat="tabform view/tabforms"
+								tal:attributes="class python:tabform.widgets.errors and 'state-error' or ''">
+								<a data-toggle="tab"
+								   tal:attributes="href string:#${tabform/id}"
+								   tal:content="tabform/tabLabel" i18n:translate="">Tab label</a>
+							</li>
+						</ul>
+						<div class="tab-content">
+							<div class="tab-pane fade in"
+								 tal:repeat="tabform view/tabforms">
+								 tal:attributes="id tabform/id"
+								 tal:content="structure tabform/render" />
+							</div>
+						</div>
+					</div>
+				</fieldset>
+			</div>
+			<footer>
+				<button tal:repeat="action view/actions/values"
+						tal:replace="structure action/render">Action</button>
+			</footer>
+		</form>
+		<div tal:replace="structure provider:form_suffix">Form suffix</div>
+	</div>
+</div>