Support Forum
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?
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/
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
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.
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
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
Sorry, I forgot to mention that It Is set in the settings.....I did set it to zero...that Is the problem
...
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.