Custom Fields
Re-Envisioned
Support MB Blocks Remove sanitize from render_template

  • Creator
    Topic
  • #24226
    Resolved Content Pilot
    Participant

    Hi,

    I built a Gutenberg block and as part of the template I have a form. There seems to be some sanitize function that is stripping that HTML tag in render_template.

    I tried with the sanitize_callback parameter with no luck. Is there any way I can remove the sanitization or modified the ruleset you are using?

    I checked this but I can’t see the MB Block code.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #24239
    Long Nguyen
    Moderator

    Hi,

    Thank you for your reporting!

    Can you please share full the code to create the block, template, and steps to happen the issue? I will try to reproduce the issue on my end. Some screenshots are very appreciated.

    #24249
    Content Pilot
    Participant

    Sure,

    You can take the extension example code, even without fields. Just add a <form></form> in the template file.

    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title'           => 'Hero Content',
            'id'              => 'hero-content',
            'description'     => 'A custom hero content block',
            'type'            => 'block',
            'icon'            => 'awards',
            'category'        => 'layout',
            'context'         => 'side',
            'render_template' => get_template_directory() . '/blocks/hero/template.php',
        ];
        return $meta_boxes;
    } );

    template.php

    echo '<div><form><button>Label</button></form></div>';

    Using render_callback doesn’t make a difference.

    #24253
    Content Pilot
    Participant

    Long, you can close this ticket. Another badly closed form tag was deleting the form that is rendered inside the block without further clues. Thanks

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