Arguments
Name | Type | Default | Description |
---|
id | string | | A unique ID. This ID will be used to get the value |
type | string | group | Type of the field |
title | string | | Title of the field |
default | array | | 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-corner (as hover/popup) of the field |
class | string | | Extra CSS classes (space separated) to append to field |
before | string | | Content to display before the field |
after | string | | Content to display after the field |
dependency | array | | Define field visibility depending on other field value |
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 | | | |
fields | array | | An associative array containing fields for the group |
max | number | 0 | Maximum number of items the user can add |
min | number | 0 | Minimum number of items the user can add |
button_title | string | Add New | Text to display on the add button |
accordion_title_prefix | string | | The text to display before title |
accordion_title_number | bool | false | Number to display before title (1 – Title, 2 – Title) |
accordion_title_auto | bool | true | Listen first input text value for title. |
Simple Group Field Example
array(
'id' => 'example-group',
'type' => 'group',
'title' => 'Example Group',
'fields' => array(
array(
'id' => 'ex-text',
'type' => 'text',
'title' => 'Example Text',
),
array(
'id' => 'ex-color',
'type' => 'color',
'title' => 'Example Color',
),
array(
'id' => 'ex-switch',
'type' => 'switcher',
'title' => 'Example Switcher',
),
),
),
Group Field Example with Defaults
array(
'id' => 'example-group',
'type' => 'group',
'title' => 'Example Group',
'fields' => array(
array(
'id' => 'ex-text',
'type' => 'text',
'title' => 'Example Text',
),
array(
'id' => 'ex-color',
'type' => 'color',
'title' => 'Example Color',
),
array(
'id' => 'ex-switch',
'type' => 'switcher',
'title' => 'Example Switcher',
),
),
'default' => array(
array(
'ex-text' => 'Example Text 1',
'ex-color' => '#ffbc00',
'ex-switch' => true,
),
array(
'ex-text' => 'Example Text Two',
'ex-color' => '#000',
'ex-switch' => false,
),
),
),
Group Field Example with Nested Fields
array(
'id' => 'example-group',
'type' => 'group',
'title' => 'Example Group',
'fields' => array(
array(
'id' => 'ex-text',
'type' => 'text',
'title' => 'Example Text',
),
array(
'id' => 'nested-group',
'type' => 'group'
'title' => 'Sub Group Example',
'fields' => array(
array(
'id' => 'ex-text-2',
'type' => 'text',
'title' => 'Sub Example Text'
),
),
),
array(
'id' => 'ex-textarea',
'type' => 'textarea',
'title' => 'Example Textarea',
),
),
'default' => array(
array(
'ex-text' => 'This is Text One',
'nested-group' => array(
array(
'ex-text-2' => 'This is text Two'
),
array(
'ex-text-2' => 'This is text Two 2',
),
),
'ex-textarea' => 'This is the text area',
),
array(
'ex-text' => 'This is text two',
'ex-textarea' => 'This is the textarea two',
),
),
),