Support Forum
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.
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"} /-->
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.
Hi Alex,
Was you able to save the post after modifying fields data?
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
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:
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.
Thanks Anh. I haven't received your email? Checked my spam box and everything.
Hi Alex, this is the screenshot of the email: https://i.imgur.com/0muIt7y.png. I sent from anhtnt@elightup.com. Can you check that again?
I'm having this same issue as well.
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.