Hide submit button based upon form

Support MB Frontend Submission Hide submit button based upon formResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #41043
    esmroscesmrosc
    Participant

    I am using the following code in wpcodebox and it does not target the actual form, where the form id is 'job-sheet-featured-aspects'. I do have multiple forms on the page and I want to hide the submit button as I am using javascript to submit the form when the toggle switch state is changed.

    It is possible to target an individual forms submit button?

    <div><?php

    add_action( 'rwmb_frontend_before_submit_button', function( $config ) {
    if( 'job-sheet-featured-aspects' === $config['id'] ){
    ?>
    <style>
    .rwmb-button-wrapper.rwmb-form-submit {
    display: none;
    }
    </style>
    <?php
    }
    });</div>

    #41045
    esmroscesmrosc
    Participant

    So I am correctly targeting the form, but the submit button is still not targeted? Is there a way to target the submit button of an individual form?

    like

    <style>
    .job-sheet-featured-aspects.rwmb-field.rwmb-button-wrapper.rwmb-form-submit {
    display: none;
    }
    </style>

    #41048
    esmroscesmrosc
    Participant

    I am also trying this code that I have been shared to aid me but it is not working

    <?php

    add_action( 'rwmb_frontend_before_submit_button', 'xxx_disable_metabox') ;

    function xxx_disable_metabox( $config ) {

    if( 'job-sheet-featured-aspects' === $config['id'] ) {

    $selector = sprintf( '.%s.rwmb-field.rwmb-button-wrapper.rwmb-form-submit', $config['id'] );
    $style = '<style>';
    $style .= $selector . '{ display: none; }';
    $style .= '</style>';

    }

    return $style;

    };

    #41053
    PeterPeter
    Moderator

    Hello,

    I see the CSS selector does not have space between classes, I think you are missing the spaces to target the button class. Please try to use this selector and let me know how it goes.

    job-sheet-featured-aspects .rwmb-form-submit .rwmb-button {
        display: none;
    }
    #41059
    esmroscesmrosc
    Participant

    #job-sheet-featured-aspects .rwmb-form-submit .rwmb-button {
    display: none;
    }

    I added the # and it worked - thank you so much - I had been going crazy over this!

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