Custom field SELECT is not saving or displaying value.

Support MB Group Custom field SELECT is not saving or displaying value.Resolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41703
    ANDREY PANFILOVANDREY PANFILOV
    Participant

    Hello.

    I have a problem with a custom SELECT field in WP Admin. This field is not saving or displaying values in the database.

    For Choices I have my function "callback: admin_get_exteriors_from_options" and checkbox "Save field value" enabled.
    The admin_get_exteriors_from_options function returns array and it's correct displayed. But haven't selected value.

    This is the code generated by MetaBox for my custom field.

    [ 'name' => __( 'exterior_color', 'your-text-domain' ), 'id' => $prefix . 'exterior_color', 'type' => 'select', 'placeholder' => __( 'PLACEHOLDER', 'your-text-domain' ), 'select_all_none' => true, 'options' => admin_get_exteriors_from_options(), ],

    What do you advise?

    #41725
    PeterPeter
    Moderator

    Hello,

    Can you please share your callback function? I've tested to create a callback function like this

    function admin_get_exteriors_from_options() {
        return [
            'red'       => 'Red',
            'green'     => 'Green',
            'blue'      => 'Blue'
    
        ];
    }

    And it works as well on my local site. Here is the field group generate code:

        $meta_boxes[] = [
            'title'    => __( 'my custom fields', 'your-text-domain' ),
            'id'       => 'my-custom-fields',
            'priority' => 'low',
            'fields'   => [
                [
                    'name'   => __( 'Group', 'your-text-domain' ),
                    'id'     => $prefix . 'group_po9o7bashyc',
                    'type'   => 'group',
                    'fields' => [
                        [
                            'name'    => __( 'Select', 'your-text-domain' ),
                            'id'      => $prefix . 'select_34gpvjxnu6a',
                            'type'    => 'select',
                            'options' => admin_get_exteriors_from_options(),
                        ],
                    ],
                ],
            ],
        ];
    
    #44373
    leebazCDSleebazCDS
    Participant

    I'm having the same problem with a callback function to populate a Select list dynamically from values stored in another custom field group within the same post.
    Did you resolve this?

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