1. Home
  2. Docs
  3. WordPress Studio Framework
  4. Framework Fields
  5. Group Field

Group Field

Arguments

NameTypeDefaultDescription
idstring A unique ID. This ID will be used to get the value
typestringgroupType of the field
titlestring Title of the field
defaultarray Default value from database, if the option doesn’t exist
subtitlestring Subtitle to display below the title
descstring Description to display after the field
helpstring Text to display on right-corner (as hover/popup) of the field
classstring Extra CSS classes (space separated) to append to field
beforestring Content to display before the field
afterstring Content to display after the field
dependencyarray Define field visibility depending on other field value
attributesarray Extra HTML attributes to append to the field
sanitizestring Callback function for sanitizing value
validatestring Callback function for validating value
EXTRAS   
fieldsarray An associative array containing fields for the group
maxnumber0Maximum number of items the user can add
minnumber0Minimum number of items the user can add
button_titlestringAdd NewText to display on the add button
accordion_title_prefixstring The text to display before title
accordion_title_numberboolfalseNumber to display before title (1 – Title, 2 – Title)
accordion_title_autobooltrueListen 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',
    ),
  ),
),
Was this article helpful to you? Yes No

How can we help?