Nuxeo Server

How to Customize the Versioning and Comment Widget on Document Edit Form

Updated: October 13, 2017 Page Information Edit on GitHub

This page is scheduled for review and update. Check back soon for updated content!

On documents edit form, a Comment textarea is displayed, and this text is visible in the History tab. When the document is versionable, versioning options are also displayed. This page provides some examples to customize this behavior using XML extensions. These examples can be contributed in Nuxeo Studio (Advanced Settings > XML Extensions) or with Nuxeo CLI.

When using a Toggleable Form (toggleableLayoutWithForms) widget type, these fields can be shown by setting the property Show Edit Options (showEditOptions) to true, and they can be hidden by setting the property to false.

On the standard edit form, on the Edit tab, the layout showing these fields is included by default. Customizing it or hiding it can be done overriding the layout named document_edit_form_options .

This layout holds three widgets that can be customized independently:

  • document_edit_current_version,
  • document_edit_versioning_options,
  • document_edit_comment .

Here is the original definition of this layout:

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="layouts">
  <layout name="document_edit_form_options">
    <templates>
      <template mode="any">/layouts/layout_default_template.xhtml
      </template>
    </templates>
    <rows>
      <row>
        <widget>document_edit_comment</widget>
      </row>
      <row>
        <widget>document_edit_current_version</widget>
      </row>
      <row>
        <widget>document_edit_versioning_options</widget>
      </row>
    </rows>
  </layout>
</extension>

Emptying This Layout for All Documents

<require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="layouts">
  <layout name="document_edit_form_options">
    <templates>
      <template mode="any">/layouts/layout_default_template.xhtml</template>
    </templates>
    <rows />
  </layout>
</extension>

Removing the Comment but Keeping Versioning Options

<require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="layouts">
  <layout name="document_edit_form_options">
    <templates>
      <template mode="any">/layouts/layout_default_template.xhtml</template>
    </templates>
    <rows>
      <row>
        <widget>document_edit_current_version</widget>
      </row>
      <row>
        <widget>document_edit_versioning_options</widget>
      </row>
    </rows>
  </layout>
</extension>

Or you can play with the hidden widget mode:

<require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="widgets">
  <widget name="document_edit_comment" type="textarea">
    <widgetModes>
      <mode value="any">hidden</mode>
    </widgetModes>
  </widget>
</extension>

Hiding the Comment Only on Some Document Types

<require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="widgets">
  <widget name="document_edit_comment" type="textarea">
    <labels>
      <label mode="any">label.editComment</label>
    </labels>
    <helpLabels>
      <label mode="any">label.editComment.tooltip</label>
    </helpLabels>
    <translated>true</translated>
    <fields>
      <field>contextData['request/comment']</field>
    </fields>
    <widgetModes>
      <mode value="any">
        #{layoutMode == 'create' or layoutValue.type == 'myType'?'hidden':'edit'}
      </mode>
    </widgetModes>
  </widget>
</extension>

Making the Comment Mandatory

<require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="widgets">
  <widget name="document_edit_comment" type="textarea">
    <labels>
      <label mode="any">label.editComment</label>
    </labels>
    <helpLabels>
      <label mode="any">label.editComment.tooltip</label>
    </helpLabels>
    <translated>true</translated>
    <fields>
      <field>contextData['request/comment']</field>
    </fields>
    <widgetModes>
      <mode value="create">hidden</mode>
    </widgetModes>
    <properties widgetMode="edit">
      <property name="required">true</property>
    </properties>
  </widget>
</extension>

Making the Comment Mandatory on a given Document Type

<require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>

<extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
  point="widgets">
  <widget name="document_edit_comment" type="textarea">
    <labels>
      <label mode="any">label.editComment</label>
    </labels>
    <helpLabels>
      <label mode="any">label.editComment.tooltip</label>
    </helpLabels>
    <translated>true</translated>
    <fields>
      <field>contextData['request/comment']</field>
    </fields>
    <widgetModes>
      <mode value="create">hidden</mode>
    </widgetModes>
    <properties widgetMode="edit">
      <property name="required">
        #{layoutValue.type == 'myType'?true:false}
      </property>
    </properties>
  </widget>
</extension>
9 days ago manonlumeau NXDOC-1346-FT review screenshot
a year ago Solen Guitter 22 | pdate how-to topic
2 years ago Anahide Tchertchian 21
2 years ago Anahide Tchertchian 20
3 years ago Manon Lumeau 19
3 years ago Solen Guitter 18
3 years ago Manon Lumeau 17
3 years ago Manon Lumeau 16
3 years ago Manon Lumeau 15
3 years ago Manon Lumeau 14
3 years ago Solen Guitter 13
3 years ago Anahide Tchertchian 12
3 years ago Solen Guitter 11
3 years ago Anahide Tchertchian 10 | NXDOC-341: fix widget mode in samples
3 years ago Anahide Tchertchian 9 | NXDOC-341: format
3 years ago Anahide Tchertchian 8 | NXDOC-341: add missing extension tags
3 years ago Solen Guitter 7
3 years ago Solen Guitter 6
3 years ago Solen Guitter 4 | Formatting
3 years ago Solen Guitter 5
3 years ago Anahide Tchertchian 2 | NXDOC-341: complete doc about edit options layout
3 years ago Anahide Tchertchian 3 | NXDOC-341: fix require tags
3 years ago Anahide Tchertchian 1
History: Created by Anahide Tchertchian