cancel
Showing results for 
Search instead for 
Did you mean: 

How to show title of document-type on edit form in Share?

vescudero
Champ in-the-making
Champ in-the-making
Hi,

is there a way to show the title of a custom document-type on edit form in Share?

Here is my code for my custom model myTypeModel.xml:


<type name="my:type">
            <title>My Type</title>
            <parent>cm:content</parent>
</type>



And here is the share-config-custom.xml:




<config evaluator="node-type" condition="my:type">
        <forms>
            <form>
                <field-visibility>
                    <show id="cm:name"/>
                    <show id="cm:title"/>
                    <show id="cm:description"/>
                    <show id="TITLE_of_my:type"/> <!– I want to show this on edit and view form –>
                </field-visibility>
            </form>
        </forms>
</config>




Thanks and regards
4 REPLIES 4

santoshbaradwaj
Champ in-the-making
Champ in-the-making
try below form config
 
————————-
<config evaluator="node-type" condition="cm:content">
   <forms>
      <form>
         <appearance>
               <set id="dublin-core" template="/org/alfresco/components/form/2-column-set.ftl" appearance="title" label="Dublin Core" />
               <field id="cmSmiley Tongueublisher" set="dublin-core" />
               <field id="cm:contributor" set="dublin-core" />
               <field id="cm:type" set="dublin-core" />
               <field id="cm:identifier" set="dublin-core" />
               <field id="cm:dcsource" set="dublin-core" />
               <field id="cm:coverage" set="dublin-core" />
               <field id="cm:rights" set="dublin-core" />
               <field id="cm:subject" set="dublin-core" />
            </appearance>
      </form>
   </forms>
</config>

Thanks for your response. I tried the above configuration but doesn't work.


<config evaluator="node-type" condition="my:type">
<forms>
<form>
<appearance>
<set id="dublin-core" template="/org/alfresco/components/form/2-column-set.ftl" appearance="title" label="Dublin Core" />
<field id="cm:publisher" set="dublin-core" />
<field id="cm:contributor" set="dublin-core" />
<field id="cm:type" set="dublin-core" />
<field id="cm:identifier" set="dublin-core" />
<field id="cm:dcsource" set="dublin-core" />
<field id="cm:coverage" set="dublin-core" />
<field id="cm:rights" set="dublin-core" />
<field id="cm:subject" set="dublin-core" />
</appearance>
</form>
</forms>
</config>


Exists other option to solve it?

zladuric
Champ on-the-rise
Champ on-the-rise
I don't know how, but I guess you should use <strong>my_customModel.type.my_type.title</strong> in there somewhere.

The workaround is to create a custom template for this and then use it in the .ftl field. something like:
        <appearance>
          <field id="bv:Document">
            <control template="my-field.ftl"/>
          </field>


Now, use the model or type name in that my-field.ftl file.

But there is probably an easier way to do this.

vescudero
Champ in-the-making
Champ in-the-making
Thanks for your idea zladuric.

Finally I have chosen to implement a easier solution. I created a custom template based on textfield.ftl that received a control param called titleType with the name of custom document-type that it will be showed on edit and view form.

textfield-custom.ftl


<#if field.control.params.titleType??>
   <#assign value = field.control.params.titleType>
<#else>
   <#assign value = "">
</#if>

<div class="form-field">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <#if field.mandatory && !(value?is_number) && value == "">
            <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 field.control.params.activateLinks?? && field.control.params.activateLinks == "true">
            <#assign fieldValue=value?html?replace("((http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?\\^=%&:\\/~\\+#]*[\\w\\-\\@?\\^=%&\\/~\\+#])?)", "<a href=\"$1\" target=\"_blank\">$1</a>", "r")>
         <#else>
            <#if value?is_number>
               <#assign fieldValue=value?c>
            <#else>
               <#assign fieldValue=value?html>
            </#if>
         </#if>
         <span class="viewmode-value"><#if fieldValue == "">${msg("form.control.novalue")}<#else>${fieldValue}</#if></span>
      </div>
   <#else>
      <span class="viewmode-label">${field.label?html}:<span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></span>
      <br/>
      <#if value?is_number>
          <#assign fieldValue=value?c>
      <#else>
          <#assign fieldValue=value?html>
      </#if>
      <span class="viewmode-value"><#if fieldValue == "">${msg("form.control.novalue")}<#else>${fieldValue}</#if></span>
   </#if>
</div>


and code in share-config-custom.xml is:


<config evaluator="node-type" condition="my:type">
        <forms>
            <form>
                <field-visibility>
                    <show id="cm:name"/>
                    <show id="cm:title"/>
                    <show id="cm:description"/>
                    <show id="my:nameType"/>
                </field-visibility>
                <appearance>
                   <field id="my:nameType" label="Title Type" mandatory="true" read-only="true">
                        <control template="/org/alfresco/components/form/controls/textfield-custom.ftl">
                            <control-param name="titleType">My Type</control-param>
                        </control>
                    </field>
                </appearance>
            </form>
        </forms>
</config>


Thanks and regards