Custom Fields
Re-Envisioned
Support Meta Box Columns Strange issue with tabs + columns

This topic contains 16 replies, has 3 voices, and was last updated by  Anh Tran 1 year, 6 months ago.

Viewing 10 replies - 1 through 10 (of 16 total)
  • Author
    Replies
  • #6322

    Jackky
    Participant

    *also can’t find any markup buttons for code wrap here, sorry

    #6323

    Jackky
    Participant

    And another my thought: maybe it will be more user-friendly to make API looking like this:

    fields => array (
        columns => array(
           size => 4,
           class => 'custom-column-class',
           fields => array (
             //you can add multiple fields here
           ),
        ),
        columns => array(
           size => 4,
           class => 'custom-column-class',
           fields => array (
             //you can add multiple fields here
           ),
        ),
        columns => array(
           size => 4,
           class => 'custom-column-class',
           fields => array (
             //you can add multiple fields here or leave empty
           ),
        ),
    )
    #6324

    Truong Giang
    Participant

    Hi there,
    Please make sure that the total of columns in meta box is multiple of 12, and all fields must have a specific columns value (Атрибуты doesn’t have one)

    #6326

    Anh Tran
    Keymaster

    Hi Jackky,

    Your idea about column class is nice. Will think about it. The suggested syntax I think will be problematic if we use with groups. So let’s just keep it as it is.

    #6332

    Jackky
    Participant

    Nope, that will be easier to use, here an example

    fields => array (
        columns => array(
           size => 4,
           class => 'custom-column-class',
           fields => array(
                'name' => 'Group', // Optional
                'id' => 'group_id',
                'type' => 'group',
                // List of sub-fields
                'fields' => array(
                    array(
                        'name' => 'Text',
                        'id' => 'text',
                        'type' => 'text',
                    ),
                    // Other sub-fields here
                ),
            ),
        ),
        columns => array(
           size => 4,
           class => 'custom-column-class',
           fields => array (
             //you can add multiple fields here
           ),
        ),
        columns => array(
           size => 4,
           class => 'custom-column-class',
           fields => array (
             //you can add multiple fields here or leave empty
           ),
        ),
    )
    #6333

    Anh Tran
    Keymaster

    Hi, I don’t want to much nested arrays. In case sub-fields in groups are organized in columns, there will be a nightmare of nested nested arrays.

    After reviewing the code, I think we can still achieve everything by this code:

    fields => array(
        array(
            'columns' => 4,
            'class'   => 'custom-column-class',
        ),
    ),

    We have class attribute for fields, so let’s use it instead of creating another attribute.

    #6347

    Jackky
    Participant

    A nightmare, yes, it will be) But you can add this like advanced markup for those crasy coders, like me) I really need a feature to wrap 2-3 fields in one column and add empty columns to build beautiful UI inside admin area. And I think, I’m not alone with this perfectionism.

    Add: also with this type of array markup there will be a feature to make nested columns.

    #6349

    Anh Tran
    Keymaster

    We just updated the Columns extension yesterday with a better check for total columns (less than or greater than 12, it will close the div). But if you use with tabs, you still need to make sure total columns in each row equals to 12. Please update.

    Regarding the new syntax, I was thinking about something advanced that can offer you more flexibility. But after looking at that, I see the change is only the fields parameter (the class as I replied can be achieved via class attribute). And with the support of Group extension, you can do that easily, including the nested columns.

    Here is what you can do with Groups (the syntax is very similar):

    'fields' => array(
        array(
            'type' => 'group', // A wrapper group
            'id' => 'wrapper',
            'fields' => array(
                array(
                    'id' => 'name',
                    'type' => 'text',
                    'columns' => 4
                ),
                array(
                    'id' => 'subgroup',
                    'type' => 'group',
                    'columns' => 8,
                    'fields' => array(), // Array of other sub-sub fields
                )
            ),
        ),
    ),
    #6363

    Jackky
    Participant

    Yes, it’s the solution for someone, but group type saving a serialized array, but I need each value stay single in case to organize searching and filtering on the front. That’s why I’m ready to deal with tonns on nested arrays in the markup example, I gave.)

    #6377

    Jackky
    Participant

    Oh, suddenly I’ve got another great idea: just make a flex-grid based extension with a markup, such as I gave. If you like it, I can generate here the full list of options.

Viewing 10 replies - 1 through 10 (of 16 total)

You must be logged in to reply to this topic.