Validate fields when plugin settings are saved

Hi,
There used to be a method maybe_save_form_settings() to trigger when the save settings button is clicked for the plugin settings. From Gravity Forms 2.5 Known Limitations - Gravity Forms Documentation, I came to know that it has been deprecated. What should be used instead maybe_save_form_settings()?

Thanks,
Amshu

Validation should be handled via the validation_callback property you can add to the array that defines the field properties, e.g.

'validation_callback' => array( $this, 'your_function_name_here' ),

You can then define that callback like so:

public function your_function_name_here( $field, $value ) {
    // Perform your custom validation.
    if ( $invalid ) { 
        $field->set_error( 'the validation message goes here' );
    }
}

If you call set_error() without passing a message, it will apply the default This field is required message.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.