Skip to main content

Section

A dynamic meta type which lets you define a group of meta a user can then create multiple instances of. A section takes all normal props, as well as inputs. Sections can be nested.

Value

Returns any[][]

$sections = json_decode(fx_get_meta('id'), true);
foreach($sections as $section) {
$title = $section['title'];
$description = $section['description'];
$image = $section['image'];
// Each section has an auto-generated unique id attached
$id = $section['_id_'];
}

Example

'id' => [
'type' => 'section',
'className' => 'my-class-name',
'limit' => null,
'defaultOpen' => true,
'tableView' => false,
'useAsTitle' => 'title',
'inputs' => [
'title' => [
'type' => 'textfield',
'title' => 'Title',
],
'description' => [
'type' => 'wp-editor',
'title' => 'Description',
],
'image' => [
'type' => 'media',
'className' => 'section-media-class',
'detailed' => true,
'multiple' => false,
'title' => 'Image',
],
],
],

Props

buttonText

Alternate text for the add button

type: string

defaultValue: 'Add'

className

Metabox class name

type: string

classPrefix

A class name prefix to forward onto children elements

type: string

defaultOpen

Pass an index to automatically open one of the sections on load. Passing true will open the last.

type: union(bool|number)

defaultValue: true

inputs

Meta inputs to render

type: object

defaultValue: {}

limit

Limit the number of sections allowed

type: number

defaultValue: undefined

noun

Noun used to describe the meta type, used when prompting for user actions, e.g. Delete 'noun'

type: string

defaultValue: 'section'

safeDelete

Ask for confirmation before deleting a section

type: bool

defaultValue: true

sortable

Allow sections to be sorted

type: bool

defaultValue: true

tableView

Present the section in a table

type: bool

title

Metabox title

type: string

useAsTitle

ID of the input to use as the section title, index will be used by default.

type: string

useModal

Move the inputs to a modal, only available when using table view.

type: bool