Skip to content

Sortable checkbox values #1632

@bernardmma

Description

@bernardmma

I've been looking into this for some time and I can't seem to figure it out. Is there a reason why my array shows '1' for checked values while the one provided in the demo gives the actual value to the key? I would like mine to also return the value of the key/value pair if possible. If that's not possible, is there an easier way to return the order of the array to use?

array(
                        'id'        => 'social-networks',
                        'type'      => 'sortable',
                        'title'     => __('Social Icons', 'options'),
                        'subtitle'  => __('Order and activate/deactivate social icons.', 'options'),
                        'mode'      => 'checkbox',
                        'options'   => array(
                            'fb' => 'Facebook',
                            'twitter' => 'Twitter',
                            'gplus' => 'Google+',
                            'pin' => 'Pinterest',
                            'tumb' => 'Tumblr',
                        )
                    ),
                    array(
                        'id'        => 'opt-sortable',
                        'type'      => 'sortable',
                        'mode'      => 'checkbox',
                        'title'     => __('Sortable Text Option', 'options'),
                        'subtitle'  => __('Define and reorder these however you want.', 'options'),
                        'desc'      => __('This is the description field, again good for additional info.', 'options'),
                        'options'   => array(
                            'si1' => 'Item 1',
                            'si2' => 'Item 2',
                            'si3' => 'Item 3',
                        )
                    ),

Using print_r returns this:

 [social-networks] => Array ( [fb] => 1 [twitter] => 1 [gplus] => 1 [pin] => 1 [tumb] => 1 ) [opt-sortable] => Array ( [si1] => Item 1 [si2] => Item 2 [si3] => Item 3 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions