Make description field hidden on custom types

I have created some custom types which contain some fiels in addtion to title (dc:title) and description (dc:description) ; now i want to make the description field hidden. I mean it will contain some data but i don't want it to be shown to users. I've made some research and found that i can use this code

<widgetModes>
  <mode value="view">#{empty layoutValue.dc.format?'hidden':'view'}</mode>
</widgetModes>

But i can't find where to put it . Any help would be appreciated.

0 votes

1 answers

1570 views

ANSWER



As you just want to hide the field from viewing in the layout, you can just create your custom layout extension. For example, you provide dc:title and dc:description in the create mode but not in the read mode. In this case the layout row and the dc:description related widget are simply removed from the layout definition.

 <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager" point="layouts">

 <layout name="layout@customType-create">
            <templates>
                <template mode="any">/layouts/custom_layout_template.xhtml</template>
            </templates>
            <rows>
                <row>
                    <properties mode="any">
                        <property name="nxl_colspan_0">1</property>
                    </properties>
                    <widget>title</widget>
                </row>
                <row>
                    <properties mode="any">
                        <property name="nxl_colspan_0">1</property>
                    </properties>
                    <widget>description</widget>
                </row>
            </rows>
            <widget name="title" type="text">
                <labels>
                    <label mode="any">Title</label>
                </labels>
                <translated>true</translated>
                <fields>
                    <field>dc:title</field>
                </fields>
                <properties widgetMode="edit">
                    <property name="styleClass">dataInputText</property>
                    <property name="required">true</property>
                </properties>
            </widget>
            <widget name="description" type="textarea">
                <labels>
                    <label mode="any">Description</label>
                </labels>
                <translated>true</translated>
                <fields>
                    <field>dc:description</field>
                </fields>
                <properties widgetMode="edit">
                    <property name="styleClass">dataInputText</property>
                </properties>
            </widget>
        </layout>

        <layout name="layout@customType-view">
            <templates>
                <template mode="any">/layouts/custom_layout_template.xhtml</template>
            </templates>
            <rows>
                <row>
                    <properties mode="any">
                        <property name="nxl_colspan_0">1</property>
                    </properties>
                    <widget>title</widget>
                </row>
            </rows>
            <widget name="title" type="text">
                <labels>
                    <label mode="any">Title</label>
                </labels>
                <translated>true</translated>
                <fields>
                    <field>dc:title</field>
                </fields>
            </widget>
        </layout>

</extension>

If the availability should be handled permission based (custom permission or user group) you can follow the guidelines here: https://doc.nuxeo.com/display/NXDOC/How+to+Control+the+Display+Mode+of+a+Widget

But in general you end up with a widgetMode entry like:

<widgetModes>
    <mode value="view">#{nxd:hasPermission(layoutValue, 'customPermission')?'view'}</mode>
</widgetModes>

Hope this info helps you.

0 votes