std value not working for Numeric field
- This topic has 7 replies, 3 voices, and was last updated 3 years, 5 months ago by
Long Nguyen.
-
AuthorPosts
-
August 25, 2021 at 4:57 PM #30429
closemarketing
ParticipantHello,
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?August 25, 2021 at 9:51 PM #30435Long Nguyen
ModeratorHi,
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/
November 22, 2021 at 2:28 AM #32086[email protected]
ParticipantHi 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
November 22, 2021 at 12:30 PM #32090Long Nguyen
ModeratorHi 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.November 22, 2021 at 3:20 PM #32091[email protected]
ParticipantHi 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
November 22, 2021 at 7:16 PM #32099Long Nguyen
ModeratorHi 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
November 22, 2021 at 8:27 PM #32101[email protected]
ParticipantSorry, I forgot to mention that It Is set in the settings.....I did set it to zero...that Is the problem
...November 23, 2021 at 11:23 AM #32111Long Nguyen
ModeratorHi,
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.
-
AuthorPosts
- You must be logged in to reply to this topic.