Custom Fields
Support MB Settings Page Clear Field value with Reset Button

  • Creator
  • #16708
    Resolved Manoj Kumar


    I need to clear my meta box field values using the Reset button on the setting page. Is there any solution to accomplish this

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

    Hi Manoj,

    The reset functionality is not built-in. You can add the following code into your theme’s functions.php file to add the reset button:

    add_action( 'mb_settings_page_submit_buttons', function() {
        submit_button( 'Reset', 'secondary', 'reset', false );
            jQuery( function( $ ) {
                $( '#reset' ).on( 'click', function( e ) {
                    $( 'input[type="text"]' ).val( '' ); // Clear input values
                    $( 'input[type="radio"],input[type="checkbox"]' ).prop( 'checked', false ); // Uncheck radio, checkbox
                } );
            } );
    } );

    The JS code is very basic and is just an idea how it works for basic fields. You might need to adjust it to make it work for other 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