AnsweredAssumed Answered

Replace selectmany form control - edit metadata

Question asked by rbowman on Dec 18, 2009
Latest reply on Dec 29, 2009 by rbowman
Hey guys.

I am having some trouble using a custom control template on a select-many field when editing metadata in share.  I have created a custom document type that pulls a list of values from a database.  In Alfresco Explorer, I have created a custom component-generator that allows me to use the id as the value and the name as the label (i.e. <option value="1">Here is my value</option>).  However, in share, the list shows the value as the label.  According to the documentation, I can override the template used to create that form field.  I have the following in my share-config-custom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config evaluator="node-type" condition="custom-type:wi">
             <show id="custom-type:location" />
             <field id="custom-type:location">
                <control template="/custom-select-many.ftl" />

I have my custom-select-many.ftl in $ALF_HOME/tomcat/shared/classes/alfresco/web-extension/site-webscripts (for now, it's the same as the regular selectmany template, but I added a test label to see if it would recognize the template):

<div class="form-field">
         <label>test label!!!!</label>
   <#if form.mode == "view">
      <div class="viewmode-field">
         <#if field.mandatory && field.value?string == "">
            <span class="incomplete-warning"><img src="${url.context}/components/form/images/warning-16.png" title="${msg("form.field.incomplete")}" /><span>
         <span class="viewmode-label">${field.label?html}:</span>
         <span class="viewmode-value">${field.value?html}</span>
      <label for="${fieldHtmlId}-entry">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
      <input id="${fieldHtmlId}" type="hidden" name="${}" value="${field.value?string}" />
      <#if field.control.params.options?exists && field.control.params.options != "">
         <select id="${fieldHtmlId}-entry" name="-" multiple="multiple" size="${size}"
               onchange="javascript:Alfresco.util.updateMultiSelectListValue('${fieldHtmlId}-entry', '${fieldHtmlId}', <#if field.mandatory>true<#else>false</#if>);"
               <#if field.description?exists>title="${field.description}"</#if>
               <#if field.control.params.styleClass?exists>class="${field.control.params.styleClass}"</#if>
               <#if field.disabled>disabled="true"</#if>>
               <#list field.control.params.options?split(",") as nameValue>
                  <#if nameValue?index_of("|") == -1>
                     <option value="${nameValue}"<#if (field.value?string?index_of(nameValue) != -1)> selected="selected"</#if>>${nameValue}</option>
                     <#assign choice=nameValue?split("|")>
                     <option value="${choice[0]}"<#if (field.value?string?index_of(choice[0]) != -1)> selected="selected"</#if>>${msgValue(choice[1])}</option>
         <div id="${fieldHtmlId}" class="missing-options">${msg("form.control.selectone.missing-options")}</div>

The problem is that the template doesn't seem to get executed.  What is really confusing is that the template will get executed if I use it on a text field instead of a list of values.  Is this a limitation of Alfresco Share?  Is there a way to provide a custom template for a select-many field??


Alfresco 3.2r
OpenSuse 11.1
MySQL 5.1
Apache 2.2.10