cancel
Showing results for 
Search instead for 
Did you mean: 

Show list as checkbox

purohitsumit
Champ in-the-making
Champ in-the-making
Hi All,

I define a task in my custom workflow as

<type name="fgwf:changeRequestTask">
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name="fgwf:reasonOfChange">
                    <type>d:text</type>
                    <default>New Data</default>
                    <constraints>
                        <constraint type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>New Data</value>
                                    <value>Error Correction</value>
                                    <value>Consistency</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>



I show this field in the share-config-custom.xml file

<field id="fgwf:reasonOfChange" set="response" />



This list shows up as combobox in the share's form. How can I get it as 3 checkbox one for each "list" value.

I tried using

<field id="fgwf:reasonOfChange" set="response" >
                      <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
                  </field>


But it shows one checkbox for property entire "fgwf:reasonOfChange" not specific list value.

Thanks
5 REPLIES 5

mlagneaux
Champ on-the-rise
Champ on-the-rise
Hello,

I think that you should create a specific template. You can take the example of the existing ftl of Alfresco in …/site-webscripts/org/alfresco/components/form/controls (perhaps selectone.ftl is the best example).

Thanks @mlagneaux,
Will try that. But it is surprising that alfresco has no in built template for this basic input type.

Thanks
sumit

I started with "selectmany.ftl" and created a 2-column list of checkbox. I am posting here is case someone else is looking for exact solution.

<div class="form-field">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <#if field.mandatory && !(fieldValue?is_number) && fieldValue?string == "">
            <span class="incomplete-warning"><img src="${url.context}/res/components/form/images/warning-16.png" title="${msg("form.field.incomplete")}" /><span>
         </#if>
         <span class="viewmode-label">${field.label?html}:</span>
         <#if fieldValue?string == "">
            <#assign valueToShow=msg("form.control.novalue")>
         <#else>
            <#if field.control.params.options?? && field.control.params.options != "" &&
                 field.control.params.options?index_of(labelSeparator) != -1>
                 <#assign valueToShow="">
                 <#assign firstLabel=true>
                 <#list field.control.params.options?split(optionSeparator) as nameValue>
                   
               <#assign choice=nameValue?split(labelSeparator)>
               
               <span class="viewmode-label">${choice[0]?html}:</span>
               <span class="viewmode-value"><#if isSelected(choice[0])>${msg("form.control.checkbox.yes")}<#else>${msg("form.control.checkbox.no")}</#if></span>
               

                 </#list>
            <#else>
               <#assign valueToShow=fieldValue>
            </#if>
         </#if>
         <span class="viewmode-value">${valueToShow?html}</span>
      </div>
   <#else>
      <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="${field.name}" value="${fieldValue?string}" />
      <#if field.control.params.options?? && field.control.params.options != "">
     <ul class="checkbox-grid">
       <#list field.control.params.options?split(optionSeparator) as nameValue>
       <li>
         <#assign choice=nameValue?split(labelSeparator)>
           <input id="${fieldHtmlId}" type="hidden" name="${choice[0]}" value="<#if isSelected(choice[0])>true<#else>false</#if>" />
          <input class="formsCheckBox" id="${fieldHtmlId}-entry" type="checkbox" tabindex="0" name="-" <#if field.description??>title="${field.description}"</#if>
             <#if isSelected(nameValue)> value="true" checked="checked"</#if>
             <#if field.disabled && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if>
             <#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
             <#if field.control.params.style??>style="${field.control.params.style}"</#if>
             onchange='javascript:YAHOO.util.Dom.get("${fieldHtmlId}").value=YAHOO.util.Dom.get("${fieldHtmlId}-entry").checked;' />
          <label for="${fieldHtmlId}-entry" class="checkbox">${choice[0]?html}</label>
          <@formLib.renderFieldHelp field=field />
    
       </li>
       </#list>
     </ul>
      <#else>
         <div id="${fieldHtmlId}" class="missing-options">${msg("form.control.selectone.missing-options")}</div>
      </#if>
   </#if>
</div>

This can be syled with following css
<code>

.checkbox-grid li {
    display: block;
    float: left;
    width: 50%;
   font-size:0.8em;
}




I am making improvement in persistence of the list and will post updated code if I do.

Thanks
sumit

</code>

Thank you for posting the  code. I am also having the same problem. I need to add a check box into my property sheet, but i couldn't able to do that. I am using Alfresco Community 5.2 edition & it is having the selectmany.ftl file which you have added. I need to know how to use that in the model manager.

I am completely new to alfresco. Please help me.

nandeesh
Champ in-the-making
Champ in-the-making

I am using alfresco process service 1.7 enterprise edition .I am facing the similar problem like add multiple options for checkbox so could you please help me out in case if you have any solutions