Support Forum
Support › MB Frontend Submission › HTML Code Formatting
I am trying to create a front-end submission form so that I can have a VA take the HTML export from an email campaign and quickly and easily post it as part of an "archive." However, when pasting the HTML into any variety of Meta Box custom fields, the output is not ideal. Here is a page that has two tabs, the first with the WordPress content when using the "Custom HTML" element in Gutenberg versus Meta Box's custom field output:
https://lyonmentalhealth.com/email-archive/first-post/
Here is the email code: https://pastebin.com/mVuxvgkH
I am not sure if I need to sanitize the data somehow or if there's something I'm missing. I see the Custom HTML field in Meta Box, but that only accepts a pre-determined HTML value (I am not aware of a way to write into that custom field type - I don't know PHP all that well). Additionally, even if I wanted to use that field, it will not create an ID, nor can I apply one and save the field group without it being blank after the fact, so I have no way to call the ID to use, even if I wanted to.
At the end of the day, I want to make this as easy as possible for a user to drop some HTML into a field and have confidence it will render as expected. The native WordPress functionality provides this, but I wanted to see if there was an alternative through Meta Box. If Meta Box is incapable of displaying the HTML like the WordPress content, is there any way to pass a Meta Box custom field value into a Custom HTML element within the WordPress content?
Hello Johnson,
By default, the value added to the Meta Box fields will be sanitized. If you want to add HTML code to a field like textarea
, please follow the documentation to bypass the sanitization of the field.
https://docs.metabox.io/sanitization/#bypass-the-sanitization
Hello, I tried that previously, before creating this post. Just to ensure I wasn't crazy, I went back in and set it up and included "none" in the sanitize advanced settings - still doesn't output the code as expected.
Again, with sanitize: none, I have this page: https://lyonmentalhealth.com/email-archive/second-post/
The first tab is the Rich Text field with sanitize none, the second tab is the WP Content field, both using the same code, both coming from the same form (I added 'title, content') to it. I don't know the intricacies of how WordPress ultimately passes that data along, but it just shows that even when going through Meta Box, the desired outcome is possible, but something isn't quite right as is.
I know this isn't fully related, but when I tried something similar using Bricksforge's Pro Forms to then make updates to the post, that's when it 'broke' the code upon a second submission. I was hoping that MetaBox would more or less permanently not sanitize the code so that on every submission, either to create a post or update it, the code would remain intact for what was passed through it. This doesn't appear to be the case, even for the initial submission.
Hello,
I see you are using Bricks Builder to output the field value, that might be the issue. Please try to use the helper function rwmb_meta()
or helper shortcode [rwmb_meta]
to output the field value without the builder and check the issue again.
https://docs.metabox.io/functions/rwmb-meta/
https://docs.metabox.io/shortcode/