Custom Fields
Re-Envisioned
Support Meta Box Group Getting label value of sub-field

This topic contains 2 replies, has 2 voices, and was last updated by  Anh Tran 3 months, 1 week ago.

  • Creator
    Topic
  • #11920
    Resolved
    badabingbreda
    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #11929

    badabingbreda
    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 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 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.