MB Blocks - Custom Field doesnt render in Gutenberg

Support MB Blocks MB Blocks - Custom Field doesnt render in Gutenberg

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41953
    Thomas WohlmuthThomas Wohlmuth
    Participant

    I´ve mad a simple Block with one custom field (text). I´ve followed the tutorial, but in Gutenberg the custom field doesnt shows up in Gutenberg.
    https://ibb.co/dLVHbZr
    https://ibb.co/JxNyH7M
    https://ibb.co/C1kSw4B

    Here are the codes:

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'       => __( 'zweier', 'your-text-domain' ),
            'id'          => 'zweier',
            'icon'        => [
                'background' => '',
                'foreground' => '#dd3333',
                'src'        => 'airplane',
            ],
            'category'    => 'oxygen-vsb-blocks',
            'supports'    => [
                'align' => [''],
            ],
            'render_code' => '{{ post_id }}
    <div class="zweierText">Hier sollte eine Textzeile sein:{{ zweierText }}</div>
    ',
            'type'        => 'block',
            'context'     => 'content',
            'fields'      => [
                [
                    'name' => __( 'Text', 'your-text-domain' ),
                    'id'   => $prefix . 'zweierText',
                    'type' => 'text',
                    'size' => 12,
                ],
            ],
        ];
    
        return $meta_boxes;
    }

    Render Code:

    {{ post_id }}
    <div class="zweierText">Hier sollte eine Textzeile sein:{{ zweierText }}</div>
    

    The Post ID renders, as well as the content of the div - expect the {{ zweierText }}

    #41962
    PeterPeter
    Moderator

    Hello,

    I do not see any issue with the render code on my demo site. Do you add the value to the field zweierText when editing the post?

    #41968
    Thomas WohlmuthThomas Wohlmuth
    Participant

    The Problem is I cant enter any Text to the Field in the Editing mode. It just doesnt show up. Even wheh I out a Placeholder, the placeholder doesnt show up

    https://ibb.co/QbLVgPh
    The Fields are not showing up in the editor
    https://ibb.co/0JmMsJ3

    #41970
    PeterPeter
    Moderator

    Hello,

    You can click on the Pen icon to edit the field, screenshot https://monosnap.com/file/3EAjEdHmHdJ6t6xzW87lz7yl4Vivjb

    Or use the context side to display the field on the right side.
    https://docs.metabox.io/extensions/mb-blocks/#context

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