Sortable

The sortable lets you add list to be sort.

Sortable

Added handler

Sortable

Parameters

Here are the parameters in adding sortable.

id
string | required

a unique slug-like string to use as an id and also as index in saving data in database.

label
string | optional

the label of the field.

description
string | optional

the description of the field and display under the label.

section
string | requiredl

the section where the field will be displayed.

default
array | optional

the default value of the field.

Note: default values must exist in items.

priority
integer | optional

determines the order of fields in section.

handle
boolean | optional

adds a handler icon.

items
array | optional

set of data to use as choices in sorting.

Example


Yano::field( 'sortable', [
   'id'          => 'sortabledb1',
   'label'       => 'Arrange Items',
   'description' => 'Please sort the list bellow.',
   'section'     => 'section_id',
   'priority'    => 1,
   'items'       => [
      1 => 'One',
      2 => 'Two',
      3 => 'Three'
   ]
] );

Example with default value! note: default values must exist in items.


Yano::field( 'sortable', [
   'id'          => 'sortabledb1',
   'label'       => 'Arrange Items',
   'description' => 'Please sort the list bellow.',
   'section'     => 'section_id',
   'default'     => [ 2, 3 ],
   'priority'    => 1,
   'items'       => [
      1 => 'One',
      2 => 'Two',
      3 => 'Three'
   ]
] );

Example with handle value! note: handle value must be boolean.


Yano::field( 'sortable', [
   'id'          => 'sortabledb1',
   'label'       => 'Arrange Items',
   'description' => 'Please sort the list bellow.',
   'section'     => 'section_id',
   'default'     => [ 2, 3 ],
   'priority'    => 1,
   'handle'      => true,
   'items'       => [
      1 => 'One',
      2 => 'Two',
      3 => 'Three'
   ]
] );

Usage

The yano_get_decoded_values() function is recommended to retrieve data.


// Returns a array
$order = yano_get_decoded_values('sortabledb1');