Custom block not saving

Support MB Blocks Custom block not savingResolved

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #15549
    AlexAlex
    Participant

    I've created this block:

    add_filter('rwmb_meta_boxes', function($meta_boxes) {
      $meta_boxes[] = [
        'title'           => 'Notice',
        'id'              => 'notice',
        'description'     => 'A notice block for emphasising spoiler alerts or providing updates',
        'type'            => 'block',
        'icon'            => 'megaphone',
        'category'        => 'layout',
        'keywords'        => ['spoiler', 'update'],
        'render_template' => get_template_directory() . '/functions/custom-blocks/notice.php',
        'supports'        => [
          'align' => ['wide', 'full'],
        ],
    
        // Block fields.
        'fields'          => [
          [
            'type'    => 'select',
            'id'      => 'type',
            'name'    => 'Type of notice',
            'options' => array(
              'spoiler' => 'Spoiler',
              'info'    => 'Info / Update'
            )
          ],
          [
            'type' => 'text',
            'id'   => 'headline',
            'name' => 'Headline',
          ],
          [
            'type'    => 'wysiwyg',
            'id'      => 'content',
            'name'    => 'Content',
            'raw'     => false,
            'options' => array(
              'textarea_rows' => 4,
              'teeny'         => true,
            ),
          ]
        ],
      ];
    
      return $meta_boxes;
    });

    It seems to work fine inside the editor. I'm able to add the block and edit fields. However, after updating the post and then refreshing the page, the inputted data is no longer there. It's not actually saving the field data.

    #15551
    AlexAlex
    Participant

    Just to add to this, after saving the post with inputted values, all it is saving to post_content is this:

    <!-- wp:meta-box/notice {"id":"block_jysrvesizrq6arbg1x7"} /-->

    #15553
    AlexAlex
    Participant

    There's definitely a bug here. After moving the block in the visual editor (i.e. up or down in relation to other blocks), only then does it reflect the latest inputted data.

    So I have to input data into the fields, then move the block up or down, and then save the post for it to stick.

    #15556
    Anh TranAnh Tran
    Keymaster

    Hi Alex,

    Was you able to save the post after modifying fields data?

    #15563
    AlexAlex
    Participant

    Hi Anh,

    Yes, I was able to save the post. The problem is inconsistent. I have created a screen recording:

    https://www.dropbox.com/s/pywk6sukuwfqaq7/custom-block-not-saving.mov?dl=0

    #15564
    AlexAlex
    Participant

    Not sure if this helps, but here's my template for it. It is being rendered correctly, except that the actual field values are empty:

    https://pastebin.com/s3TzxGxg

    #15565
    Anh TranAnh Tran
    Keymaster

    Hi Alex,

    Thanks a lot for your video and code. I've sent you an email with a fix for MB Blocks. Please try it along with the updated version of Meta Box on Github and let me know how it goes.

    #15567
    AlexAlex
    Participant

    Thanks Anh. I haven't received your email? Checked my spam box and everything.

    #15569
    Anh TranAnh Tran
    Keymaster

    Hi Alex, this is the screenshot of the email: https://i.imgur.com/0muIt7y.png. I sent from [email protected]. Can you check that again?

    #15725
    stevenhardinstevenhardin
    Participant

    I'm having this same issue as well.

    #15729
    Anh TranAnh Tran
    Keymaster

    Hey Steven,

    I've just updated MB Blocks to 1.0.4 to address this issue. I have confirmed with Alex that it's working. Please update the extension.

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