# Sortable

The Sortable field allows for an unlimited array of drag-and-drop text box inputs or check boxes.

# Arguments

Name Type
Default
Description
type string sortable Value identifying the field type.
options array Array of key pair data defining the input objects.  The key represents the object's ID.  The second the display text.  See the example.
label bool false Flag to display values before text areas when mode is not checkbox.
mode string text Sets the mode of the input HTML. Options allowed are text or checkbox.

# Build Config

Build a Custom Configuration →
Changes you make to this form will be reflected in the generated code.
Field visibility requirements.

Redux::set_field( 'OPT_NAME', 'SECTION_ID', array(
    'type' => 'sortable'
) );

# Example Config

// Checkbox mode
Redux::addField( 'OPT_NAME', 'SECTION_ID', array(
    'id'       => 'text-sortable',
    'type'     => 'sortable',
    'title'    => __('Sortable Text Option', 'redux-framework-demo'),
    'subtitle' => __('Define and reorder these however you want.', 'redux-framework-demo'),
    'desc'     => __('This is the description field, again good for additional info.', 'redux-framework-demo'),
    'mode'     => 'checkbox',
    'options'  => array(
        '1'     => 'Item 1',
        '2'     => 'Item 2',
        '3'     => 'Item 3',
    ),
    // For checkbox mode
    'default' => array(
        '1' => false,
        '2' => true,
        '3' => false
    ),
) );

# Text mode


Redux::addField( 'OPT_NAME', 'SECTION_ID', array(
    'id'       => 'text-sortable',
    'type'     => 'sortable',
    'title'    => __('Sortable Text Option', 'redux-framework-demo'),
    'subtitle' => __('Define and reorder these however you want.', 'redux-framework-demo'),
    'desc'     => __('This is the description field, again good for additional info.', 'redux-framework-demo'),
    'mode'     => 'text',
    'options' => array(
         '1' => 'Item number one',
         '2' => 'Number two here',
         '3' => 'Three strikes, yer out!',
    ),
) );

# Example Usage

This example in based on the example usage provided above. Be sure to change $redux_demo to the value you specified in your opt_name argument.

global $redux_demo;

echo 'Text 1 value' . $redux_demo['text-sortable']['1'];
echo 'Text 2 value' . $redux_demo['text-sortable']['2'];
echo 'Text 3 value' . $redux_demo['text-sortable']['3'];