|
/ Documentation /Getting Started/ How to Change Checkbox Value from “On” to “Yes” (or Custom Text)

How to Change Checkbox Value from “On” to “Yes” (or Custom Text)

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.

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:

__( "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 filter in your theme’s functions.php file or a custom plugin.

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