Strange behavior of some fields options

Support Meta Box AIO Strange behavior of some fields optionsResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36690
    Alaan TVAlaan TV
    Participant

    It has been 2 months since I started using your amazing plugin, but I've faced some repeated issues when using the following options of the custom fields which I think is not sense:

    • disabled: When I save the post, the disabled fields will store an empty value on DB. Is it something related to WordPress behavior? Or it's a bug that needs a fix?
    • save_field: If this option was false, the value will not be saved to DB which is OK, but the value will not be queried from DB as well. Why I can't see the value if it's already saved on DB?

    Appreciate your support with this.

    Best Regards,

    #36696
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for reaching out. Let me answer your questions.

    1. I do not see that issue on my end. If the field is newly created without any value saved before, then after you save the post, there is no empty value will be saved. Can you please share a screen record of this issue on your site?

    2. If the setting save_field is set to false so we do not need to know what the field value is. The field will not look in the database to display the field value because it is redundant/unnecessary.
    You can use the setting std to set the default value for a field in this case.

    #36703
    Alaan TVAlaan TV
    Participant

    Thank you for the hint!

    I managed to resolve it using the std option, like this:

    $meta_boxes[] = [
        'title'          => 'My settings',
        'id'             => 'my_settings_id',
        'settings_pages' => ['my_settings_page'],
        'tab'            => 'my_settings_tab',
        'fields'         => [
            [
                'name'       => 'My field',
                'id'         => 'my_field_id',
                'type'       => 'text',
                'std'        => get_option( 'my_settings_id' )['my_field_id'],
                'disabled'   => true,
                'save_field' => false,
            ],
        ]
    ]
    

    So the value will never be saved to DB, and I'm able now to see the value of the same field safely.

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