Getting label value of sub-field

Support MB Group Getting label value of sub-fieldResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11920
    badabingbredabadabingbreda
    Participant

    Hi,

    I've added the group extensions sample code that creates the Album Tracks on a CPT.
    I retrieve the value of field 'standard' using $value = rwmb_meta( $field_id );

    I can access the value of genre using: $genre = $value[0]['genre'];

    However, the returned values are always the key-values, and I don't see an option to change that to either label or key-label value pairs. How can I go about to return the labels instead?

    Thanks, I'm hoping I'm just missing something here.

    #11929
    badabingbredabadabingbreda
    Participant

    Ok, so I ended up writing a walker function to fix this. If there's I setting I missed please let me know.

    #11934
    Anh TranAnh Tran
    Keymaster

    It's great that you found a solution. I think the rwmb_get_field_settings() function can help a little. It gives you the group field settings and then you can get the options for sub-field.

    $group = rwmb_get_field_settings( 'group' );
    $sub_field = $group['fields'][0];
    $group_value = rwmb_meta( 'group' );
    $sub_field_value = $group_value[0]['sub_field'];
    
    $label = $sub_field['options'][$sub_field_value];
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.