Skip to content

Instantly share code, notes, and snippets.

@rilwis
Created April 17, 2017 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rilwis/d6635c18cca81aaa4a593d4c178b456b to your computer and use it in GitHub Desktop.
Save rilwis/d6635c18cca81aaa4a593d4c178b456b to your computer and use it in GitHub Desktop.
Hierarchical select/checkbox_list
<?php
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
$meta_boxes[] = array(
'title' => 'Test',
'fields' => array(
array(
'type' => 'select_tree', // or checkbox_list
'id' => 'cb',
'name' => 'Hierarchical checkboxes',
'options' => array(
array( 'value' => 'value1', 'label' => 'label 1' ),
array( 'value' => 'value2', 'label' => 'label 2' ),
array( 'value' => 'sub1', 'label' => 'Sub 1', 'parent' => 'value1' ),
array( 'value' => 'sub2', 'label' => 'Sub 2', 'parent' => 'value1' ),
),
'flatten' => false,
),
),
);
return $meta_boxes;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment