Reply To: Add Select Values from Other Custom Fields
Support › General › ✅Add Select Values from Other Custom Fields › Reply To: Add Select Values from Other Custom Fields
December 6, 2018 at 2:44 PM
#12520
Keymaster
Hi Pete,
The MB Builder doesn't allow you to use dynamic values from other fields at the moment. You need to create the meta box and field by code.
Here is an example:
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
$post_id = null;
if ( isset( $_GET['post'] ) ) {
$post_id = intval( $_GET['post'] );
} elseif ( isset( $_POST['post_ID'] ) ) {
$post_id = intval( $_POST['post_ID'] );
}
$options = array(
'w' => get_post_meta( $post_id, 'w', true ),
'ru' => get_post_meta( $post_id, 'ru', true ),
// and so on.
);
$meta_boxes[] = [
'title' => 'Your title',
'fields' => [
[
'type' => 'select',
'id' => 's',
'name' => 'Select',
'options' => $options,
],
],
];
} );