Arguments
Name | Type | Default | Description |
---|
id | string | | A unique ID. This ID will be used to get the value |
type | string | code_editor | Type of the field |
title | string | | Title of the field |
default | string | | Default value from database, if the option doesn’t exist |
subtitle | string | | Subtitle to display below the title |
desc | string | | Description to display after the field |
help | string | | Text to display on right-corder (as hover/popup) of the field |
class | string | | Extra CSS classes (space separated) to append to the field |
before | string | | Content to display before the field |
after | string | | Content to display after the field |
dependency | array | | Define field visibility to append to the field |
attributes | array | | Extra HTML attributes to append to the field |
sanitize | string | | Callback function for sanitizing value |
validate | string | | Callback function for validating value |
EXTRAS | | | |
settings | array | | An associative array containing arguments for the setting |
settings Arguments
Name | Type | Default | Description |
---|
mode | string | htmlmixed | Sets the language mode of the editor (css, javascript, php, htmlmixed) |
theme | string | default | Sets the theme of the editor (mbo, monokai, ambiance) |
lineNumbers | bool | true | Flag to display line numbers to the left of the editor |
tabSize | number | 2 | The width of a tab space |
Get more information from the codemirror arguments
Simple Code Editor Example
array(
'id' => 'example-code-editor',
'type' => 'code_editor',
'title' => 'Code Editor',
),
HTML Code Editor Example
array(
'id' => 'example-html-editor',
'type' => 'code_editor',
'title' => 'HTML Editor',
'settings' => array(
'theme' => 'mdn-like',
'mode' => 'htmlmixed',
),
'default' => '<h1>Hello World</h1>',
),
CSS Code Editor Example
array(
'id' => 'example-css-editor',
'type' => 'code_editor',
'title' => 'CSS Editor',
'settings' => array(
'theme' => 'mbo',
'mode' => 'css',
),
'default' => '.element{ color: #ffbc00; }',
),
Javascript Code Editor Example
array(
'id' => 'example-js-editor',
'type' => 'code_editor',
'title' => 'Javascript Editor',
'settings' => array(
'theme' => 'monokai',
'mode' => 'javascript',
),
'default' => 'console.log("Hello World");',
),
Was this article helpful to you?
Yes
No