michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

Sortable checkbox problem #271

Closed mnajafzadeh closed 6 years ago

mnajafzadeh commented 6 years ago

Type of issue

Prerequisites

Steps to reproduce the issue (for Bug report)

  1. Install the plugin downloaded form https://wordpress.org/plugins/admin-page-framework/
  2. Enable the Demo
  3. In WP Dashboard, go to APF Demo > Built-in Field Types
  4. Go to Selectors tab
  5. Under Check-boxes section the Sortable is not working as expected. Following I explained how to find this,

Expected behavior and actual behavior

I changed the code as follow to have one of the columns like q, r, s

            array( // sortable check boxes
                'field_id'      => 'checkbox_sortable_fields',
                'title'         => __( 'Sortable', 'admin-page-framework-loader' ),
                'type'          => 'checkbox',
                'label'         => array( 'x', 'y', 'z' ),
                'sortable'      => true,
                array(
                    'label'         => array( 'q', 'r', 's' ),
                ), // the second item
                array(), // the third item
                array(), // the fourth item
            )

Them I dragged the q, e, s row to the end and clicked Save. I was expecting to have the row at the end but, it stays at the same place and only the checked items are moved to the last.

Environment

Browsers

Operating System

Versions

Isolating the problem

michaeluno commented 6 years ago

I was expecting to have the row at the end but, it stays at the same place and only the checked items are moved to the last.

That's how it is supposed to be. It's not a bug. You are just changing the labels of the second row, which is applied every time the rows are rendered.

If you need to let the user sort set of check boxes with different labels, you want to try nested fields or inline fields.

mnajafzadeh commented 6 years ago

Hi,

What I meant was that, the labels for check boxes are not sorting. It is only sorting the checked values!

I want to let user to sort a set of checkbox elements. Could you please, show me an example?

Thank you.

michaeluno commented 6 years ago

here https://gist.github.com/michaeluno/3c1d4d1ca39305787780f882fd7bb080