Get current field label when in a Meta Box field group (Twig)

Support MB Group Get current field label when in a Meta Box field group (Twig)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34339
    MikeMike
    Participant

    I'm doing this through MB Views, so using the mb. format for the following PHP commands.

    Let me start by clarifying a couple things, to save time:
    - the answer is not in this group (at least it is not findable).
    - there is a post that says this can be done using rwmb_get_field_settings() but that does not do what I need (it does not return the current saved value of fields).

    Via a MetaBox View, I can get the current field label and / or value using rwmb_the_value() or rwmb_get_the_value and post ID.

    However, this does not work if the field is within a group.

    We can call this a bug, as there is no reason the field ID should not be accessible directly, whether or not it is part of a group. Otherwise using groups is not really worthwhile (which would be a shame as they are good for organisation).

    Perhaps the answer to this question can also be added to the rwmb_the_value() / rwmb_get_the_value() documentation.

    Thanks

    #34355
    Long NguyenLong Nguyen
    Moderator

    Hi Mike,

    Is that the label of a select field (value => Label)? You can access it via the label property like this {{ post.group.select.label }}

    Or do you mean the field name?

    [
        'name'    => __( 'Select', 'your-text-domain' ), // here
        'id'      => $prefix . 'select',
        'type'    => 'select',
        'options' => [
            'a' => __( 'A', 'your-text-domain' ),
            'b' => __( 'B', 'your-text-domain' ),
            'c' => __( 'C', 'your-text-domain' ),
        ],
    ],
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.