dynamic custom HTML in text field

Support MB Blocks dynamic custom HTML in text fieldResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #32771
    DANIEL FITIPALDO R.DANIEL FITIPALDO R.
    Participant

    Hi,

    I am using the MB Blocks to create content in Gutenberg. I have created a block to enter content in edit mode with one of the fields of type 'text' and I use the attribute 'after' to create HTML content to display after the text. Is there any possibility that this custom HTML attribute was dynamic based on the content entered in the associated text field? for example, create a dynamic hyperlink using the a or link tags taking into consideration the value of the text field entered manually in edit mode?.
    My field:

     [
                    'id'    => $prefix . '_test_text_field',
                    'type'  => 'text',
                    'after' => __( 'custom HTML displayed after the field output that I would like to be dynamic', 'your-text-domain' ),
                ],
    
    

    Any guideling will be welcome.
    Thanks.
    Daniel

    #32774
    Long NguyenLong Nguyen
    Moderator

    Hi Daniel,

    You can use the field appearance filter rwmb_{$field_id}_end_html to add some HTML code with field value after the field. For example:

    add_filter( 'rwmb_test_text_field_end_html', function( $end, $field, $meta ) {
        $end = 'custom HTML displayed after the field output that I would like to be dynamic - ' . $meta . '</div><!-- .rwmb-input -->';
        return $end;
    }, 10, 3 );

    Replace the field ID test_text_field with your real ID. Refer to this documentation https://docs.metabox.io/filters/#rwmb_end_html

    #32775
    DANIEL FITIPALDO R.DANIEL FITIPALDO R.
    Participant

    Great! thank you, this is what I needed!.
    you can close this ticket as resolved.

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