1. Home
  2. Developer
  3. Code Snippets
  4. Replacing Select with Checkboxes
  1. Home
  2. Developer
  3. How-To Guides
  4. Replacing Select with Checkboxes

Replacing Select with Checkboxes

Sometimes you are asking for extra permission say opt-in to SMS

Sometimes you need to ask for extra permissions in the application form, for example you may want to provide an opt-in for SMS.

This information will be saved in Bullhorn as a yes/no value, which Matador will display as a dropdown by default.

You may want to display a single checkbox instead, here is an example of how to do this (the Bullhorn field we are working with is called customText23)

add_filter( 'matador_application_fields_structure', static function( $structure ){
      
        $structure['customText23']['type'] = 'checkbox'; // change type to checkbox
        unset($structure['customText23']['options']['No']); //remove the no option
        unset($structure['customText23']['label']); // remove the label
        // make the label for the yes option to the question
        $structure['customText23']['options']['Yes'] = 'SMS Opt-In: By checking this box, I give my permissi
on to Primary Services to send me SMS text messages with new job opportunities and career news. Standard tex
t messaging rates may apply.';

return $structure;
} , 10, 1 );

// hook into the raw data we get back from form
add_filter('matador_application_data_raw', static function($request) {

        if (isset($request['customText23'])) {
              // check the check box is set to yes and set the correct value for Bullhorn
                if (in_array('Yes', $request['customText23'])) {
                        $request['customText23'] = 'Yes';
                }else{
                        $request['customText23'] = 'No';
                }
        }
        return $request;
});
Updated on October 23, 2023
Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support