cancel
Showing results for 
Search instead for 
Did you mean: 

Template '2-column-edit-form.ftl' showing exception

ebuild
Champ on-the-rise
Champ on-the-rise
I have added the form template  "2-column-edit-form.ftl" from http://docs.alfresco.com/5.0/tasks/forms-custom-formtemplate.html

When editing the document form I got this error:

Exception: freemarker.core.InvalidReferenceException - The following has evaluated to null or missing: ==> form.items [in template "2-column-edit-form.ftl" at line 25, column 16] Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)?? The failing instruction (print stack trace for 7 more): ==> #list form.items as item [in template "2-column-edit-form.ftl" at line 25, column 9]

I'm using Alfresco 5.0d, any clue ?
1 REPLY 1

anon26949
Star Contributor
Star Contributor

I had the same problem. This template helped:

<#import "/org/alfresco/components/form/form.lib.ftl" as formLib />
<script type="text/javascript">
   /*
    function isFormContainer(e) {
        ret = YAHOO.util.Dom.hasClass(e, 'form-container');
        return (ret);
    }   
    var form_container0 = YAHOO.util.Dom.getElementsByClassName('form-container', 'div');
    var form_container1 = YAHOO.util.Dom.getElementBy(isFormContainer, 'div');
    var form_container2 = document.querySelectorAll(".form-container");
    var name = document.getElementsByName("prop_cm_name")[0];
    var form_container = name.parentNode.parentNode.parentNode.parentNode;
    alert(form_container);
    YAHOO.util.Dom.setStyle(form_container, 'width', "80em");
    */

</script>

<#if error?exists>
   <div class="error">${error}</div>
<#elseif form?exists>

   <#assign formId=args.htmlid + "-form">
   <#assign formUI><#if args.formUI??>${args.formUI}<#else>true</#if></#assign>

   <#if formUI == "true">
      <@formLib.renderFormsRuntime formId=formId />
   </#if>
  
   <div id="${formId}-container" class="form-container">
     
      <#if form.showCaption?exists && form.showCaption>
         <div id="${formId}-caption" class="caption"><span class="mandatory-indicator">*</span>${msg("form.required.fields")}</div>
      </#if>
        
      <#if form.mode != "view">
         <form id="${formId}" method="${form.method}" accept-charset="utf-8" enctype="${form.enctype}" action="${form.submissionUrl}">
      </#if>
     
      <div id="${formId}-fields" class="form-fields">
        <#list form.structure as item>
            <#if item.kind == "set">
               <@renderSetWithColumns set=item />
            <#else>
               <@formLib.renderField field=form.fields[item.id] />
            </#if>
         </#list>
      </div>
        
      <#if form.mode != "view">
         <@formLib.renderFormButtons formId=formId />
         </form>
      </#if>

   </div>
</#if>

<#macro renderSetWithColumns set>
   <#if set.appearance?exists>
      <#if set.appearance == "fieldset">
         <fieldset><legend>${set.label}</legend>
      <#elseif set.appearance == "panel">
         <div class="form-panel">
            <div class="form-panel-heading">${set.label}</div>
            <div class="form-panel-body">
      </#if>
   </#if>
  
   <#list set.children as item>
      <#if item.kind == "set">
         <@renderSetWithColumns set=item />
      <#else>
         <#if (item_index % 2) == 0>
         <div class="yui-g"><div class="yui-u first">
         <#else>
         <div class="yui-u">
         </#if>
         <@formLib.renderField field=form.fields[item.id] />
         </div>
         <#if ((item_index % 2) != 0) || !item_has_next></div></#if>
      </#if>
   </#list>
  
   <#if set.appearance?exists>
      <#if set.appearance == "fieldset">
         </fieldset>
      <#elseif set.appearance == "panel">
            </div>
         </div>
      </#if>
   </#if>
</#macro>

See cggh-alfresco-extensions/2-column-edit-form.ftl at master · cggh/cggh-alfresco-extensions · GitHub