Content definitions overrides json samples

  Written by The Jahia Team
 
Developers
   Estimated reading time:

Content definition overrides samples

1. Add a new section to Content Editor (CE)

Add the fieldset metadata to the jnt:text form

File: META-INF/jahia-content-editor-forms/forms/jnt_text.json

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

2. Hide a field in CE

Hide the j:street field in the jmix:locationAware fieldset

File: 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
    }
  ]
}

3. Set a field as readOnly

Set the j:street field in the jmix:locationAware fieldset as readOnly

File: 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
    }
  ]
}

4. Hide a fieldset

Hide the fieldset jmix:categorized

File: META-INF/jahia-content-editor-forms/fieldsets/jmix_categorized.json

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

5. Add a constraint to a field.

Add a regular expression to the mail adress

File: 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,}"
        }
      ]
    }
  ]
}

6. Change the order of the fields inside a fieldset

You need to add the rank property in the definition of the form

File: META-INF/jahia-content-editor-forms/fieldsets/jmix_tagged.json

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

7. Change a section label

File: 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"
    }
  ]
}

Note that label.engineTab.publication should be present in your .properties file