Skip to main content

Custom Fields

Troubleshooting Custom Fields

Common problems with custom fields in the new Edit Content, and how to fix them.

SymptomCause and fix
There is no Implementation option in the field dialog.Turn on Enable Edit Content Beta for the content type; see Content Editor.
My migrated field still shows the old Dojo UI.It's still set to Deprecated, so the part of its code after #else runs. Switch it to Recommended. See Recommended vs. Deprecated.
A class does nothing.It isn't one of the included classes, or it uses brackets such as mt-[10px]. See Styling Custom Fields.
DotCustomFieldApi.get is not a functionWrap the field's code in DotCustomFieldApi.ready().
Two custom fields interfere with each other.They're on the same page. Use <script type="module">, keep code inside ready(), and start ids with the field's name.
My CSS changed other parts of the editor.Styles in a custom field apply to the whole page. Target only your own elements, for example with an id.
The input is red as soon as the form opens.Only show the error after the editor has interacted: state.invalid && state.touched.
Opening content marks it as changed.Your code sets a value when the form opens. Pass { markDirty: false } to setValue.
hide() does nothing.Switch the custom field that calls it to Recommended, or add any Recommended custom field to the form.
getValue() returns undefined, other methods have no effect, and onChange logs Field 'x' not found in form in the console.The variable name passed to getField() doesn't match any field on the form. Check its spelling on the content type.
openBrowserModal calls onClose with null right away, and no picker opens.The picker only exists in the new content editor.
An image picked with openBrowserModal doesn't load.It's a dotAsset. Build its address as /dA/ followed by its identifier, as in the tutorial.
An icon won't hide.Wrap it in a <span> and hide the span.