 Holger Frey
					
					8 years ago
						Holger Frey
					
					8 years ago
					
				
				 3 changed files with 149 additions and 0 deletions
			
			
		| @ -0,0 +1,97 @@@@ -0,0 +1,97 @@ | ||||
| <form | ||||
|   tal:define="style style|field.widget.style; | ||||
|               css_class css_class|string:${field.widget.css_class or field.css_class or ''}; | ||||
|               item_template item_template|field.widget.item_template; | ||||
|               autocomplete autocomplete|field.autocomplete; | ||||
|               title title|field.title; | ||||
|               errormsg errormsg|field.errormsg; | ||||
|               description description|field.description; | ||||
|               buttons buttons|field.buttons; | ||||
|               use_ajax use_ajax|field.use_ajax; | ||||
|               ajax_options ajax_options|field.ajax_options; | ||||
|               formid formid|field.formid; | ||||
|               action action|field.action or None; | ||||
|               method method|field.method;" | ||||
|   tal:attributes="autocomplete autocomplete; | ||||
|                   style style; | ||||
|                   class css_class; | ||||
|                   action action;" | ||||
|   id="${formid}" | ||||
|   method="${method}" | ||||
|   enctype="multipart/form-data" | ||||
|   accept-charset="utf-8" | ||||
|   i18n:domain="deform" | ||||
|   > | ||||
| 
 | ||||
|   <fieldset class="deform-form-fieldset"> | ||||
| 
 | ||||
|     <legend tal:condition="title">${title}</legend> | ||||
| 
 | ||||
|     <input type="hidden" name="_charset_" /> | ||||
|     <input type="hidden" name="__formid__" value="${formid}"/> | ||||
| 
 | ||||
|     <div class="alert alert-danger" tal:condition="field.error"> | ||||
|       <div class="error-msg-lbl" i18n:translate="" | ||||
|         >There was a problem with your submission</div> | ||||
|       <div class="error-msg-detail" i18n:translate="" | ||||
|         >Errors have been highlighted below</div> | ||||
|       <p class="error-msg">${field.errormsg}</p> | ||||
|     </div> | ||||
| 
 | ||||
|     <p class="section first" tal:condition="description"> | ||||
|       ${description} | ||||
|     </p> | ||||
| 
 | ||||
|     <div tal:repeat="child field" | ||||
|          tal:replace="structure child.render_template(item_template)"/> | ||||
| 
 | ||||
|     <div class="form-actions deform-form-buttons"> | ||||
|       <tal:loop tal:repeat="button buttons"> | ||||
|         <button | ||||
|               tal:define="btn_disposition repeat.button.start and 'btn-primary' or 'btn-default'; | ||||
|               btn_icon button.icon|None" | ||||
|               tal:attributes="disabled button.disabled if button.disabled else None" | ||||
|               id="${formid+button.name}" | ||||
|               name="${button.name}" | ||||
|               type="${button.type}" | ||||
|               class="btn ${button.css_class or btn_disposition}" | ||||
|               value="${button.value}"> | ||||
|           <i tal:condition="btn_icon" class="${btn_icon}"> </i> | ||||
|           ${button.title} | ||||
|         </button> | ||||
|       </tal:loop> | ||||
|     </div> | ||||
| 
 | ||||
|   </fieldset> | ||||
| 
 | ||||
|   <script type="text/javascript" tal:condition="use_ajax"> | ||||
|    deform.addCallback( | ||||
|      '${formid}', | ||||
|      function(oid) { | ||||
|        var target = '#' + oid; | ||||
|        var options = { | ||||
|          target: target, | ||||
|          replaceTarget: true, | ||||
|          success: function() { | ||||
|            deform.processCallbacks(); | ||||
|            deform.focusFirstInput(target); | ||||
|          }, | ||||
|          beforeSerialize: function() { | ||||
|            // See http://bit.ly/1agBs9Z (hack to fix tinymce-related ajax bug) | ||||
|            if ('tinymce' in window) { | ||||
|              $(tinymce.get()).each( | ||||
|                function(i, el) { | ||||
|                  var content = el.getContent(); | ||||
|                  var editor_input = document.getElementById(el.id); | ||||
|                  editor_input.value = content; | ||||
|              }); | ||||
|            } | ||||
|          } | ||||
|        }; | ||||
|        var extra_options = ${ajax_options} || {}; | ||||
|        $('#' + oid).ajaxForm($.extend(options, extra_options)); | ||||
|      } | ||||
|    ); | ||||
|   </script> | ||||
| 
 | ||||
| </form> | ||||
| @ -0,0 +1,51 @@@@ -0,0 +1,51 @@ | ||||
| <div tal:define="error_class error_class|field.widget.error_class; | ||||
|                  description description|field.description; | ||||
|                  title title|field.title; | ||||
|                  oid oid|field.oid; | ||||
|                  hidden hidden|field.widget.hidden; | ||||
|                  category category|field.widget.category; | ||||
|                  structural hidden or category == 'structural'; | ||||
|                  required required|field.required;" | ||||
|      class="control-group ${field.error and 'has-error' or ''} ${field.widget.item_css_class or ''} ${field.default_item_css_class()}" | ||||
|      title="${description}" | ||||
|      id="item-${oid}" | ||||
|      tal:omit-tag="structural" | ||||
|      i18n:domain="deform"> | ||||
| 
 | ||||
|   <label for="${oid}" | ||||
|          class="control-label ${required and 'required' or ''}" | ||||
|          tal:condition="not structural" | ||||
|          id="req-${oid}" | ||||
|          > | ||||
|     ${title} | ||||
|   </label> | ||||
| 
 | ||||
|   <div class="controls"> | ||||
| 
 | ||||
|       <div tal:define="input_prepend field.widget.input_prepend | None; | ||||
|                        input_append field.widget.input_append  | None" | ||||
|            tal:omit-tag="not (input_prepend or input_append)" | ||||
|            class="input-group"> | ||||
|         <span class="input-group-addon" | ||||
|               tal:condition="input_prepend">${input_prepend}</span | ||||
|         ><span tal:replace="structure field.serialize(cstruct).strip()" | ||||
|         /><span class="input-group-addon" | ||||
|                 tal:condition="input_append">${input_append}</span> | ||||
|       </div> | ||||
| 
 | ||||
|       <p class="help-inline" | ||||
|          tal:define="errstr 'error-%s' % field.oid" | ||||
|          tal:repeat="msg field.error.messages()" | ||||
|          i18n:translate="" | ||||
|          tal:attributes="id repeat.msg.index==0 and errstr or | ||||
|          ('%s-%s' % (errstr, repeat.msg.index))" | ||||
|          tal:condition="field.error and not field.widget.hidden and not field.typ.__class__.__name__=='Mapping'"> | ||||
|         ${msg} | ||||
|       </p> | ||||
| 
 | ||||
|       <p tal:condition="field.description and not field.widget.hidden" | ||||
|          class="help-inline" > | ||||
|         ${field.description} | ||||
|       </p> | ||||
|     </div> | ||||
| </div> | ||||
		Reference in new issue