OSM field in group warnings and no map rendered

Support MB Views OSM field in group warnings and no map renderedResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26511
    Yoann AubryYoann Aubry
    Participant

    The only way I have found to make the binding feature work between osm field, search field and text fields (like city, postcode...) is to put all fields in the same group.

    It works in the backoffice but the page made with mb view display some warnings and the map is not rendered anymore.

    My php export :

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Lots à bâtir', 'your-text-domain' ),
            'id'         => 'lots-a-batir',
            'post_types' => ['lot-a-batir'],
            'geo'        => true,
            'fields'     => [
                [
                    'name'              => __( 'Prix', 'your-text-domain' ),
                    'id'                => $prefix . 'text_prix',
                    'type'              => 'text',
                    'label_description' => __( 'Prix sans symbole euro (€)', 'your-text-domain' ),
                ],
                [
                    'name'              => __( 'Superficie', 'your-text-domain' ),
                    'id'                => $prefix . 'number_superficie',
                    'type'              => 'number',
                    'label_description' => __( 'Superficie m²', 'your-text-domain' ),
                ],
                [
                    'name'   => __( 'Localisation', 'your-text-domain' ),
                    'id'     => $prefix . 'location',
                    'type'   => 'group',
                    'fields' => [
                        [
                            'name' => __( 'Chercher', 'your-text-domain' ),
                            'id'   => $prefix . 'address',
                            'type' => 'text',
                            'desc' => __( 'Saisir une adresse à localiser', 'your-text-domain' ),
                        ],
                        [
                            'name'          => __( 'Rue', 'your-text-domain' ),
                            'id'            => $prefix . 'street',
                            'type'          => 'text',
                            'binding'       => 'road',
                            'address_field' => 'address',
                        ],
                        [
                            'name'          => __( 'Code postal', 'your-text-domain' ),
                            'id'            => $prefix . 'postcode',
                            'type'          => 'text',
                            'binding'       => 'postcode',
                            'address_field' => 'address',
                        ],
                        [
                            'name'          => __( 'Village', 'your-text-domain' ),
                            'id'            => $prefix . 'city',
                            'type'          => 'text',
                            'binding'       => 'town',
                            'address_field' => 'address',
                        ],
                        [
                            'name'          => __( 'Ville', 'your-text-domain' ),
                            'id'            => $prefix . 'ville',
                            'type'          => 'text',
                            'binding'       => 'city',
                            'address_field' => 'address',
                        ],
                        [
                            'name'          => __( 'Osm', 'your-text-domain' ),
                            'id'            => $prefix . 'osm_map',
                            'type'          => 'osm',
                            'address_field' => 'address',
                            'language'      => 'fr',
                            'region'        => 'fr',
                        ],
                    ],
                ],
         
                
       
            ],
        ];
    
        return $meta_boxes;
    }

    The warnings :

    Warning:  Illegal string offset 'single' in .../web/prod/wp-content/plugins/meta-box/inc/field.php on line 178
    
    Warning:  array_merge(): Expected parameter 1 to be an array, string given in /home/.../web/prod/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-views/src/Fields/MapRenderer.php on line 12 

    If I put all fields to the root wthout group, the binding between osm field and search field works but not between others text fields.

    I have a 5.3.8 Meta-box and all meta-box-aio extensions up to date. `

    What I am missing ?

    #26522
    Long NguyenLong Nguyen
    Moderator

    Hi,

    There was a problem while getting the OSM sub-field in View. Please use it as a top-field, not inside a group to make it works, I will check this case and let you know later.

    Fields:

    $meta_boxes[] = [
        'title'      => __( 'Lots à bâtir', 'your-text-domain' ),
        'id'         => 'lots-a-batir',
        'post_types' => ['post'],
        'geo'        => true,
        'fields'     => [
            [
                'name'              => __( 'Prix', 'your-text-domain' ),
                'id'                => $prefix . 'text_prix',
                'type'              => 'text',
                'label_description' => __( 'Prix sans symbole euro (€)', 'your-text-domain' ),
            ],
            ...
            [
                'name'          => __( 'Osm', 'your-text-domain' ),
                'id'            => $prefix . 'osm_map',
                'type'          => 'osm',
                'address_field' => 'address',
                'language'      => 'fr',
                'region'        => 'fr',
            ],
            
    
        ],
    ];
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.