Bug: Clonable map field not displaying data

Support General Bug: Clonable map field not displaying dataResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #45109
    Maxim AkimovMaxim Akimov
    Participant

    Steps to Reproduce:

    1. Add the OS map field to a Field Group and enable the clonable option.
    2. Populate the value and save the post.
    3. Attempt to display or retrieve the field value using 'rwmb_the_value' or 'rwmb_get_value'.

    Current Behavior:

    The maps are not displayed, and the returned data is empty.

    Expected Behavior:

    The maps should be displayed, and the returned data should not be empty.

    Details:

    The workaround mentioned in the documentation for the map field inside the group does not work. While it functions for editors, it appears that the clonable option is not supported for Map fields.

    MetaBox v5.9.5

    #45119
    PeterPeter
    Moderator

    Hello,

    Following the documentation https://docs.metabox.io/fields/osm/#outputting-a-map-in-a-group
    Please change the class RWMB_Map_Field to RWMB_OSM_Field and recheck this issue

    echo RWMB_OSM_Field::render_map( $group_value['osm'], $args );
    
    #45136
    Maxim AkimovMaxim Akimov
    Participant

    Hi Peter,

    The suggested solution doesn't work.
    I also tried to use the code provided by the 'Theme code' widget, but it doesn't work either.

    Please note that it's not a sub-field within a group, but a Map field type with the repeatable option enabled.

    #45144
    PeterPeter
    Moderator

    Hello,

    The code to display the cloneable map is similar to the subfield map in the group. Here is an example:

    $maps = get_post_meta( get_queried_object_id(), 'osm_field_id', true );
    
    $args = [
        'width'  => '640px',
        'height' => '480px',
    ];
    
    foreach ( $maps as $map ) {
    	echo RWMB_OSM_Field::render_map( $map, $args );
    }
    #45153
    Maxim AkimovMaxim Akimov
    Participant

    Hi,

    Thank you, the suggested code works.

    It seems there's an issue with the Theme Code widget in MB Builder suggesting incorrect code for this scenario, as rwmb_get_value function isn't suitable in this case, even as a base for extra processing.

    It would be beneficial if the Theme Code widget would show the proper code snippet.

    Also, it would be helpful to include guidance on using the get_post_meta function on the Docs page for clarity on the clonable case.

    Thanks again and have a good weekend.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.