Data are not saved into the database.

Support MB Group Data are not saved into the database.Resolved

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #11633

    We have a following code part:

    https://ghostbin.com/paste/55sv6

    When the page is saved, answer field is not always saved into database. DB records looks like this:

    
    a:5:{i:0;a:2:{s:8:"question";s:10:"Question 1";s:6:"answer";s:8:"Answer 1";}i:1;a:2:{s:8:"question";s:10:"Question 2";s:6:"answer";s:8:"Answer 2";}i:2;a:2:{s:8:"question";s:10:"Question 3";s:6:"answer";s:8:"Answer 3";}i:3;a:1:{s:8:"question";s:10:"Question 4";}i:4;a:1:{s:8:"question";s:10:"Question 5";}}
    
    

    It most cases it happens with the row number equal greater than 4.

    #11639
    Anh TranAnh Tran
    Keymaster

    Hi,

    When I unserialize the value, I see questions and answers are saved correctly:

    https://www.unserialize.com/s/54991f6e-ab47-be68-7bdc-00006081513b

    FYI, the group extension saves all sub-field values in a serialized array in the database (which is what you just saw). When you get the value, it will be unserialized and returns an array.

    #11649

    Anh,

    Thanks for checking however if I go to the link you provided I can see row 3 and 4 is without an answer

    Vadym

    #11658
    Anh TranAnh Tran
    Keymaster

    Hi Vadym,

    Can you take a screenshot of the edit screen with all questions and answers?

    #11665
    #11684
    Anh TranAnh Tran
    Keymaster

    Hi Vadym,

    I see you're using Gutenberg. This editor saves custom fields via ajax calls. So, can you try waiting for 1-2 seconds after post is saved, just to make sure the custom fields's ajax call is finished, and check the data again?

    #11726

    Anh,

    Do you mean to wait 1-2 seconds and reload the page? If so results are the same. They are not simply saved into the database. This is what is get posted to the WP:

    
    gu_field_faq[0][question]: Question 1
    gu_field_faq[0][answer]: Answer 1
    gu_field_faq[1][question]: Question 2
    gu_field_faq[1][answer]: Answer 2
    gu_field_faq[2][question]: Question 3
    gu_field_faq[2][answer]: Answer 3
    gu_field_faq[3][question]: Q4
    gu_field_faq[3][answer]:
    

    As you can see, last answer is empty. If I switch to the Classic editor this issue does not happen. So it looks like MetaBox does not play nicely with the Gutenberg.

    Is following article still accurate?

    https://metabox.io/meta-box-is-compatible-with-gutenberg/

    Also this may be relevant too:

    https://github.com/WordPress/gutenberg/issues/5718

    Any suggestions what to do?

    • Vadym
    #11749
    Anh TranAnh Tran
    Keymaster

    Hi Vadym,

    Thanks a lot for your links. I've tested again and experienced the same problem. This issue is something related to the way Gutenberg saves data from TinyMCE editors. It's a bug in the Gutenberg and was reported here. The developer team seems not to have a final solution at the moment. The only workaround is running window.tinyMCE.triggerSave() before saving posts.

    #12524
    Anh TranAnh Tran
    Keymaster

    Hi Vadym,

    I've just added a fix on Github. Please check it. Thanks.

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