Defining Module Settings
Learn how to define module settings using the field types provided by Divi.
Note: This tutorial series is intended for advanced users. At least a basic understanding of coding in PHP and JavaScript is required.
Module settings are defined in the get_fields()
method of the module’s PHP class. A setting definition is simply an associative array of parameters.
Required Parameters
- type (string) — The field type used to render the setting in the module settings modal
Optional Parameters
- default (string) — Default value
- description (string) — Description (localized)
- id (string) — CSS id for the setting’s field
- label (string) — Display name (localized)
- option_category (string) — Option category slug (for the Divi Role Editor)
- show_if (array) — Only show the setting when certain settings have certain values
- show_if_not (array) — Only show the setting when certain settings do not have certain values
- tab_slug (string) — Modal tab slug
- toggle_slug (string) — Modal tab settings group toggle slug
Field Types
The Divi Builder has a comprehensive selection of field types for module settings. Below you’ll find a list of available field types, each with a screenshot and a list of any additional parameters that must be included in the setting definition. The value to use for the type
parameter of the setting definition is in parenthesis next to each field type name.
Text (text)
Select (select)
Select Field Parameters
- options (array) — Option slugs mapped to their display names (localized)
Checkboxes (multiple_checkboxes)
Checkboxes Field Parameters
- options (array) — Option slugs mapped to their display names (localized)
Toggle Button (yes_no_button)
Toggle Button Field Parameters
- options (array)
- off (string) — Display name for the “off” state (localized)
- on (string) — Display name for the “on” state (localized)
Range Slider (range)
Range Slider Field Parameters
- range_settings (array)
- min (string) — Minimum value
- max (string) — Maximum value
- step (string) — Minimum distance between values when using the slider
- validate_unit (bool) — Whether or not to validate unit