Custom Fields
Support MB Frontend Submission Unsetting fields & changing placeholder/required before rendering form

  • Creator
  • #16565
    Resolved pza

    I’m having w/this: I want to dynamically change form field attributes on a Frontend Submission form. I mean fields, not the shortcode attrs like “post_title” etc. I’m making metaboxes with MB builder.

    Using action rwmb_frontend_before_form I am able to set field default values with rwmb_{fieldid}_field_meta filter.

    BUT I also want to change “required” & “placeholder” , and conditionally remove some fields.

    I tried using the rwmb_normalize_{fieldid}_field filter but it doesn’t work. Maybe I’m thinking of this wrong.

    Can you please suggest how I can conditionally remove fields on a FES form, and change field placeholder/required attributes?


Viewing 1 replies (of 1 total)
  • Author
  • #16585
    Anh Tran

    Hi @pza, I’m thinking about using some code like this:

    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $fields = [];
        if ( ! is_admin() ) {
            $fields[] = [...]; // A front-end-only field.
        $text_field = [
            'id' => 't',
            'name' => 'Text',
        if ( ! is_admin() ) {
            $text_field['required'] = true; // Change field settings only on the front end.
        $fields[] = $text_field;
        $meta_boxes[] = [
            'id' => 'custom-mb',
            'title' => 'Custom Meta Box',
            'fields' => $fields,
    } );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash