Hello Rilwis, thank you for this great extension, I am able to retrieve the parent values, but not the values from the subfields, here is my code:
add_filter( 'rwmb_meta_boxes', 'saq_metas' );
function saq_metas( $meta_boxes ) {
$meta_boxes[] = array(
'title' => __( 'Questions and Answers' ),
'post_types' => 'saq',
'fields' => array(
array(
'id' => 'saq_id',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
// Sub-fields
'fields' => array(
array(
'name' => __( 'Question', 'bs_saq' ),
'id' => 'question',
'type' => 'text',
),
array(
'name' => __( 'Answer', 'bs_saq' ),
'id' => "answer",
'type' => 'wysiwyg',
'raw' => false,
'std' => esc_html__( '', 'bs_saq' ),
'options' => array(
'textarea_rows' => 4,
'teeny' => true,
'media_buttons' => false,
),
),
array(
'name' => __( 'Supplementary Information', 'textdomain' ),
'id' => 'supplementary',
'type' => 'group',
'clone' => true,
'fields' => array(
// Sub title
array(
'name' => __( 'Supplementary info title', 'textdomain' ),
'id' => 'sub_text',
'type' => 'text',
),
// Sub info
array(
'name' => __( 'Supplementary info text', 'textdomain' ),
'id' => 'sub_textarea',
'type' => 'textarea',
),
),
),
),
),
),
);
return $meta_boxes;
}
I would really appreciate if you can guide me, I tried this:
$group_values = rwmb_meta( 'supplementary' );
foreach ( $group_values as $group_value ) {
$value = isset( $group_value['sub_text'] ) ? $group_value['sub_text'] : '';
echo $value;
}
but it says to me "Warning: Invalid argument supplied for foreach() in" on line 19 and line 19 is this one:
foreach ( $group_values as $group_value ) {
I am confused, please help, thank you!