Custom block not saving
- This topic has 10 replies, 3 voices, and was last updated 5 years, 9 months ago by
Anh Tran.
-
AuthorPosts
-
August 1, 2019 at 10:04 PM #15549
Alex
ParticipantI'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.
August 1, 2019 at 10:18 PM #15551Alex
ParticipantJust 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"} /-->
August 1, 2019 at 10:44 PM #15553Alex
ParticipantThere'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.
August 2, 2019 at 9:04 AM #15556Anh Tran
KeymasterHi Alex,
Was you able to save the post after modifying fields data?
August 2, 2019 at 2:12 PM #15563Alex
ParticipantHi 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
August 2, 2019 at 2:59 PM #15564Alex
ParticipantNot sure if this helps, but here's my template for it. It is being rendered correctly, except that the actual field values are empty:
August 2, 2019 at 3:34 PM #15565Anh Tran
KeymasterHi 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.
August 2, 2019 at 4:25 PM #15567Alex
ParticipantThanks Anh. I haven't received your email? Checked my spam box and everything.
August 2, 2019 at 4:35 PM #15569Anh Tran
KeymasterHi Alex, this is the screenshot of the email: https://i.imgur.com/0muIt7y.png. I sent from [email protected]. Can you check that again?
August 17, 2019 at 1:28 AM #15725stevenhardin
ParticipantI'm having this same issue as well.
August 17, 2019 at 3:07 PM #15729Anh Tran
KeymasterHey 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.
-
AuthorPosts
- You must be logged in to reply to this topic.