Custom Fields
Re-Envisioned
Support General Checkbox Tree Questions

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 2 years, 1 month ago.

  • Creator
    Topic
  • #5785

    alpha.media
    Participant

    I had some questions in regards to the checkbox tree options. Is there a way to have a select all in this meta box type? Also is there a way to access the data before it is saved?

    Let’s see that I have the following setup:

    – Parent Element
    – Child Element
    – Child Element

    When selecting the Parent Element, I want the value to be equal to all the child elements. It doesn’t appear to select children elements so I was hoping maybe I can access the data of the Parent Element when saving to the database and split into array items with the rest of the multiple selects?

    So if it was value1,value2,value3 as the value of a parent item, it can be split into the array with the rest of the non parent items selected somewhere else in the checkbox tree. I hope this all makes sense. If it’s not possible, may just have to build a custom meta box.

    The main needs are the ability to have a tree or header above sections and make selecting groups of options very easy to do.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #5786

    Anh Tran
    Keymaster

    Hi,

    All the options (parent or children) are treated equally. And you have to select individual items so save the value. So if you select the parent element, it doesn’t auto select all of its children. You still need to manually check each of them. This way you can select only some of them, not all nor none.

    In case you want to toggle all the selection, you can add a parameter 'select_all_none' => true. However, it works with all options.

    To populate the value before it’s saved, you can use the filter rwmb_{$field_id}_value.

    Hope that helps.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.