Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the powerful-docs domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/spectra-qa-sites/webapps/sureforms-staging-qa/wp-includes/functions.php on line 6131

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the convertpro-addon domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/spectra-qa-sites/webapps/sureforms-staging-qa/wp-includes/functions.php on line 6131

Notice: Function WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script() function instead. Please see Debugging in WordPress for more information. (This message was added in version 5.7.0.) in /home/spectra-qa-sites/webapps/sureforms-staging-qa/wp-includes/functions.php on line 6131
How to Change Checkbox Submission Value from “On” to “Yes” or Custom Text in SureForms - SureForms
|
/ Documentation /Developer Documentation/Action Hooks/ How to Change Checkbox Submission Value from “On” to “Yes” or Custom Text in SureForms

How to Change Checkbox Submission Value from “On” to “Yes” or Custom Text in SureForms

By default, when a user selects a checkbox in a SureForm, the submitted value appears as “on”. If you want to change this value to something more user-friendly like “Yes” or localize it based on the site language, you can easily do this using a filter.

PHP
add_filter('srfm_before_prepare_submission_data', function($submission_data) {
    foreach ($submission_data as $key => $value) {
        if (strpos($key, 'srfm-checkbox') !== false || strpos($key, 'srfm-gdpr') !== false) {
            $submission_data[$key] = ($value === "on") ? __( "Yes", "sureforms") : __( "No", "sureforms");
        }
    }
    return $submission_data;
});

How it works:

  • This filter runs before form data is saved or sent.
  • It checks if the submitted field is a checkbox.
  • If selected, it replaces “on” with “Yes”.
  • The __() function ensures it’s translation-ready if you’re building a multilingual site.

Customize for your language or terms:

You can modify the “Yes” to fit your site’s tone or language. For example:

PHP
__( "Ja", "sureforms") // German
__( "Oui", "sureforms") // French
__( "Sim", "sureforms") // Portuguese

To ensure the custom text shows correctly in email notifications or webhook data, make sure to place this code in your child theme’s functions.php file or use a plugin like Code Snippets to safely insert custom code. Using a code snippet plugin is recommended for easier management and to ensure the code remains active even if you switch themes.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Scroll to Top