Skip to content

Accordion Field

Overview

The accordion field type allows you to group multiple fields under collapsible accordion sections. This is useful for organizing form elements in a structured and user-friendly way.

Field Configuration

Below is the general structure for defining an accordion field:

php
array(
    'id'         => 'example_accordion',
    'type'       => 'accordion',
    'title'      => 'Example Accordion',
    'accordions' => array(
        array(
            'title'  => 'Accordion 1',
            'fields' => array(
                array(
                    'id'    => 'text_one',
                    'type'  => 'text',
                    'title' => 'Text',
                ),
                array(
                    'id'    => 'textarea_one',
                    'type'  => 'textarea',
                    'title' => 'Text Area',
                ),
            )
        ),
    )
),

Specific Parameters

ParameterTypeDefaultDescription
accordionsarray-Contains an array of accordion sections.
title (inside accordions)string-Title for each individual accordion section.
iconstringfas fa-angle-rightTitle for each individual accordion section.
fieldsarray-Array of fields contained within the accordion section.

General Parameters

ParameterTypeDefaultDescription
idstring-Unique identifier for the field.
typestring-Defines the field type.
titlestring-The title displayed for the field.
subtitlestring-The text displayed under the title.
classstring-Field additional class.
data_typestringserializeDefines how data is stored (e.g., serialize).
namestring-Custom name for the field.
placeholderstringNot selectedPlaceholder text for the input.
attributesarrayarray()Custom HTML attributes.
beforestring-Content to display before the field.
afterstring-Content to display after the field.
descriptionstring-A detailed description of the field.
descstring-A short description, used if description is not set.
helpstring-Additional helper text for guidance. Usually show on the top right corner of the field.
errorstring-Error message to display when validation fails.
dependenciesarray-Show/Hide a field base on another field value.

Example Usage

Here’s an example of how an accordion field might be defined in a settings panel:

php
array(
    'id'    => 'custom_settings',
    'type'  => 'accordion',
    'title' => 'Custom Settings',
    'accordions' => array(
        array(
            'title'  => 'General Settings',
            'fields' => array(
                array(
                    'id'    => 'site_name',
                    'type'  => 'text',
                    'title' => 'Site Name',
                ),
                array(
                    'id'    => 'site_description',
                    'type'  => 'textarea',
                    'title' => 'Site Description',
                ),
            )
        ),
    )
),

Notes

  • Each accordion section can contain multiple fields of various types.
  • You can customize each section with different fields as required.
  • This structure helps in keeping form fields organized and user-friendly.