Added 'id' attribute for inner forms
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 13:35:48 +0200
changeset 58 6302819f15be
parent 57 cb847dfb3e11
child 59 67e09cabd072
Added 'id' attribute for inner forms
src/pyams_form/templates/inner-form.pt
--- a/src/pyams_form/templates/inner-form.pt	Mon Sep 11 13:34:18 2017 +0200
+++ b/src/pyams_form/templates/inner-form.pt	Mon Sep 11 13:35:48 2017 +0200
@@ -1,5 +1,8 @@
 <div class="no-padding"
-	 tal:attributes="class string:${view.css_class} no-padding">
+	 tal:define="content_name getattr(view.getContent(), '__name__', 'noname');
+				 content_name content_name.replace('++', '');"
+	 tal:attributes="class string:${view.css_class} ${view.padding_class | default};
+					 id string:${context.__class__.__name__}_${content_name}_${view.id};">
 	<div tal:define="prefix provider:form_prefix"
 		 tal:replace="structure prefix">Form prefix</div>
 	<form method="post"
@@ -24,7 +27,10 @@
 		<fieldset tal:define="legend view.legend"
 				  tal:attributes="class view.fieldset_class | nothing"
 				  tal:omit-tag="not:legend">
-			<legend class="inner" tal:condition="legend">
+			<legend class="inner" tal:condition="legend"
+					tal:define="legend_class view.legend_class | nothing"
+					tal:attributes="class string:inner ${legend_class};
+									data-ams-switcher-state view.switcher_state | nothing;">
 				<i tal:attributes="class view.icon_css_class | nothing"></i>
 				<tal:var content="legend">Legend</tal:var>
 				<tal:var condition="python:getattr(view, 'show_widget_title', False)"
@@ -141,6 +147,8 @@
 					tal:replace="structure action.render()">Action</button>
 		</footer>
 	</form>
-	<div tal:define="prefix provider:form_prefix"
-		 tal:replace="structure prefix">Form prefix</div>
+	<div class="form-suffix"
+		 tal:define="suffix provider:form_suffix"
+		 tal:condition="suffix"
+		 tal:content="structure suffix">Form suffix</div>
 </div>