Support Forum ยป User Profile

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: โœ…How to get field settings #20783
    AlexAlex
    Participant

    Thank you Long. That should work.

    in reply to: โœ…How to get field settings #20759
    AlexAlex
    Participant

    I have front-end React app. I am using WordPress as headless CMS. The post doesn't exists yet. Hence I do not have post_id to pass it to the function. The idea is when a user opens form to create a new post, one of the fields is the Country select field. I was hoping to get options for this front-end field by fetching options from the custom Country back-end field. It is not a direct access. My app fires REST request to the custom endpoint. The custom endpoint function uses rwmb_get_field_seetings to get options and send it back to the from-end app. Is it even possible with Metabox? It did work with ACF.

    Thanks.

    in reply to: โœ…How to get field settings #20754
    AlexAlex
    Participant

    Hi Long,
    Yes, I did use $field_id. It seems none of the helper functions work. I tried a few other with no success. The fields are visible in the Post. I can change the values.

    Here is just part of the Metabox.

    function.php

    add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes');
    function prefix_register_meta_boxes($meta_boxes) {
        if (!class_exists('RW_Meta_Box')) {
            return;
        }
        /*=================================================
        * Properties Custom Type Metabox
        ===================================================*/
        $meta_boxes[] = array(
            'id' => 'property-meta-box',
            'title' => esc_html__( 'Property', 'textdomain' ),
            'pages' => array('property'),
            'tabs' => array(
                'property_location' => array(
                    'label' => esc_html__('Location', 'textdomain'),
                    'icon' => 'dashicons-location',
                ),
            ),
            'tab_style' => 'left',            
            'fields' => array(
                array (
                    'id' => 'country',
                    'name' => esc_html__( 'Country', 'textdomain' ),
                    'type' => 'select',
                    'placeholder' => esc_html__( 'Select an Item', 'textdomain' ),
                    'options' => array(
                        1 => esc_html__( 'Canada', 'textdomain' ),
                        2 => esc_html__( 'United States', 'textdomain' ),
                    ),
                    'tab' => 'property_location',
                    'columns' => 12,
                ),
    ),
    );
    return $meta_boxes;
    }
    
    $field = rwmb_get_field_settings('country');
    
Viewing 3 posts - 1 through 3 (of 3 total)