std value not working for Numeric field

Support General std value not working for Numeric field

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #30429
    closemarketingclosemarketing
    Participant

    Hello,
    I'm trying to use a default value but in numeric field is not working. std is supposed to work, but not.
    How could use a default value?

    #30435
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I didn't see any issue with the setting std of the field number.

    'fields' => [
        [
            'name' => __( 'Number', 'your-text-domain' ),
            'id'   => $prefix . 'number_meta',
            'type' => 'number',
            'std'  => 123,
        ],
    ],

    Can you please share the code that creates the fields? And follow the Debugging Information step to troubleshoot the issue https://support.metabox.io/topic/how-to-create-a-new-topic/

    #32086
    dagonero68@gmail.com[email protected]
    Participant

    Hi Long,
    I decided to ask here so I won't be opening another thread...
    The standard value for a number field doens't work for me either, I set to 0 but is empty when I create a new post...
    Any clue?

    Angelo

    #32090
    Long NguyenLong Nguyen
    Moderator

    Hi Angelo,

    Please share the code that creates the number field and a screen record on your site after you deactivate all plugins except Meta Box and switch to the standard theme of WordPress.

    #32091
    dagonero68@gmail.com[email protected]
    Participant

    Hi Long,
    I tried to deactivate all plugins except Oxygen,Metabox and Metabox AIO, no luck...
    Although I use the visual version of metabox, If I go to "Generate PHP" to grab the code the result is as follows:

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
    $meta_boxes[] = [
        'title'      => __( 'Prezzo vendita', 'your-text-domain' ),
        'id'         => 'prezzo-vendita',
        'post_types' => ['vendita'],
        'fields'     => [
            [
                'name'          => __( 'VALORE VENDITA', 'your-text-domain' ),
                'id'            => $prefix . 'valore_vendita',
                'type'          => 'number',
                'step'          => 'any',
                'required'      => true,
                'admin_columns' => 'after Title',
            ],
        ],
    ];
    return $meta_boxes;
    }

    It is a development site, if you want the credentials pls let me know

    #32099
    Long NguyenLong Nguyen
    Moderator

    Hi Angelo,

    As you can see on your code, there is no setting std of the number field.

    [
        'name' => __( 'Number', 'your-text-domain' ),
        'id'   => $prefix . 'number_4mgm8pyvpnu',
        'type' => 'number',
        'std'  => 111,
    ],

    In the builder, you can add the default value to the option "Default value", screen record https://share.getcloudapp.com/Jrun5n5g

    #32101
    dagonero68@gmail.com[email protected]
    Participant

    Sorry, I forgot to mention that It Is set in the settings.....I did set it to zero...that Is the problem
    ...

    #32111
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks, I see that. Please use the code instead of the builder. I will inform the development team to support this case in future updates.

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