switch field type - not saving 0 in the database

Support General switch field type - not saving 0 in the databaseResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38757
    Prabakaran ShankarPrabakaran Shankar
    Participant

    Hi,
    The switch field not saving 0 in the database. only stores 1 in the database along with field name. I have noticed this behaviour in the group subfield.
    Is this the intended format?

    #38765
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Yes, it is the default behavior of MB Group to prevent saving empty values to the database (just raw/minimalist values). You can see on the documentation https://docs.metabox.io/extensions/meta-box-group/#sub-field-values

    #38772
    Prabakaran ShankarPrabakaran Shankar
    Participant

    Thank you for your information.
    If possible, please edit the document Switch#data
    Because it says: "Switch field stores the "on" and "off" status in the database as "1" or "0"."

    #38774
    Long NguyenLong Nguyen
    Moderator

    Hi,

    When you use the switch field as a top field, the value 0 is saved to the database as well. It will not be saved when the field is a subfield in a group.

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