Add a native “Code” field type (in addition to new JSON field) #17135
Unanswered
alexanderbuergin
asked this question in
Ideas
Replies: 1 comment
-
Check out the Code Field plugin, which provides a general-purpose code editor powered by Monaco. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, I really appreciate the new JSON field added in Craft 5.7 – that’s a welcome addition and a clear step forward.
That said, I believe it would also be meaningful to introduce a native “Code” field type for general-purpose source code input.
With the JSON field, we now have a way to store and validate a specific format of code. But there’s still no native field for other code types – like HTML, JavaScript, or snippets that don’t fit neatly into the JSON structure.
Of course, one can use a plain text field, enable line breaks, and apply a monospaced font in the control panel. But a dedicated Code field would make this more explicit, consistent, and semantically clear. It could offer syntax highlighting or at least be visually optimized for editing code.
Use cases are abundant:
• Google Analytics or Tag Manager snippets
• HTML embed codes
• Structured configuration blocks
• Twig or JS templates
• Small code references that shouldn’t live in the site templates, but rather in a CMS-editable context
Since there is now a JSON field (which, in the end, is also just a form of source code), it feels like a natural next step to offer a more generic Code field alongside it.
Would love to hear what you think about this.
Beta Was this translation helpful? Give feedback.
All reactions