Examples of content definition JSON overrides

  Written by The Jahia Team
 
Developers
   Estimated reading time:

This topic provides examples of content definition JSON overrides that you can use to customize your Content Editor forms.

Adding a new section

The following JSON example adds fieldset metadata to the jnt:text form. You can find the file on github at src/test/resources/META-INF/jahia-content-editor-forms/forms/jnt_text.json.

{
  "name": "jnt:text",
  "priority": 1.0,
  "sections": [
    {
      "name": "metadata"
    }
  ]
}

Hiding a field

The following JSON example hides the j:street field in the jmix:locationAware fieldset. You can find the file on github at META-INF/jahia-content-editor-forms/fieldsets/jmix_locationAware.json.

{
  "name": "jmix:locationAware",
  "displayName": "Location",
  "description": "",
  "dynamic": true,
  "activated": false,
  "fields": [
    {
      "name": "j:street",
      "removed": true
    }
  ]
}

Setting a field to read only

The following JSON example sets the j:street field in the jmix:locationAware fieldset to read only. You can find the file on github at META-INF/jahia-content-editor-forms/fieldsets/jmix_locationAware.json.

{
  "name": "jmix:locationAware",
  "displayName": "Location",
  "description": "",
  "dynamic": true,
  "activated": false,
  "fields": [
    {
      "name": "j:street",
      "readOnly": true
    }
  ]
}

Hiding a fieldset

The following JSON example hides the jmix:categorized fieldset. You can find this file on github at src/test/resources/META-INF/jahia-content-editor-forms/fieldsets/jmix_categorized.json.

{
  "name": "jmix:categorized",
  "priority": 1.0,
  "removed": true
}

Adding a constraint to a field

The following JSON example adds a regular expression to the mail address. You can find the file on github at META-INF/jahia-content-editor-forms/fieldsets/jnt_person.json.

{
  "name": "jnt:person",
  "displayName": "Person portrait",
  "description": "",
  "dynamic": true,
  "activated": false,
  "fields": [
    {
      "name": "email",
      "valueConstraints": [
        {
          "value": {
            "type": "String",
            "value": "^$|[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}"
          },
          "displayValue": "^$|[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,}"
        }
      ]
    }
  ]
}

Changing the order of fields in a fieldset

The following JSON example changes the order of fields in a fieldset based on their rank value. Note that you must add the rank property in the definition of the form. You can find the file on github at META-INF/jahia-content-editor-forms/fieldsets/jmix_tagged.json.

{
  "name": "jmix:tagged",
  "priority": 1.0,
  "fields": [
    {
      "name": "j:tagList",
      "target": {
        "rank": 1
      }
    }
  ]
}

Changing a section label

The following JSON example changes a section label. Note that label.engineTab.publication should be present in your .properties file. You can find the file on github at META-INF/jahia-content-editor-forms/forms/jnt_news.json.

{
  "name": "jnt:news",
  "priority": 1.0,
  "sections": [
    {
      "name": "content",
      "labelKey": "label.engineTab.publication",
      "requiredPermission": "viewContentTab"
    }
  ]
}