Skip to main content

Custom Fields

Creating a Custom Field

This walkthrough adds a Recommended custom field called URL Slug to a content type. The code itself is explained in the tutorial; here the focus is the content type editor.

Turn On the New Edit Content for the Content Type#


Open the content type, select Settings, check Enable Edit Content Beta and select Update, as described in Content Editor. Without this, you won't see the Implementation option. The checkbox is per content type and can be turned off again at any time.

Add a Custom Field#


Drag Custom Field from the field list on the right into a row. The field dialog opens.

Name It and Choose Recommended#


Enter a Name. dotCMS creates the field's variable name from it (URL Slug becomes urlSlug); you'll use it in your code. The variable name can't be changed after you save. Under Implementation, select Recommended.

Write the Template in Value#


Paste your code into Value. Add a Hint if editors need guidance, and check Required if the content can't be saved without a value.

Custom Field dialog, Overview tab: Name URL Slug, Implementation set to Recommended, and the start of the template in the Value editor.

Name, Implementation and Value are required. Hint, Required and the other options are further down the Overview tab and work as on any other field.

Save, Then Review Settings and Field Variables#


Select Save. When you open the field again, the Settings tab appears and Field Variables becomes available:

  • Settings has Hide Label, for fields that show their own label. Recommended fields only have this option.
  • Field Variables shows newRenderMode = component, which is how dotCMS stores your Recommended choice.

All the options are listed in Custom Field Reference.

Open the Content Editor#


Create or edit content of that type. The field renders inline with the editor's own fonts, inputs and buttons.

New content form with Title, the URL Slug custom field showing a /blog/ prefix input, an Empty badge, a 0 / 60 counter and a Generate from title button.