0

My function:

     function _custom_get_ublox_communication_checkbox_form_element() {
  return array(
    '#type' => 'checkboxes',
    '#title' => t('Communications'),
    '#options' => array(
      1 => t('I consent to retaining my personal data for the purposes of receiving personalized marketing materials, offers, invitations to webinars and other similar events. To learn more, read our <a )),
    ),

    '#required' => TRUE,
  );
}

This checkbox is mandatory as there is option '#required' => TRUE, but after removing the required option it is not even removing the required(*) check from the field.

halfer
  • 19,824
  • 17
  • 99
  • 186
syed1234
  • 761
  • 5
  • 12
  • 30

1 Answers1

0

If you want to use only one checkbox element , you should use 'checkbox' type instead of 'checkboxes'

https://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7.x#checkbox

So if you don't need it to be required , use FALSE value

function _custom_get_ublox_communication_checkbox_form_element() {
  return array(
    '#type' => 'checkbox',
    '#title' => t('I consent to retaining my personal data for the purposes of receiving personalized marketing materials, offers, invitations to webinars and other similar events. To learn more, read our <a'),
    '#required' => FALSE,
  );
}

Clear all caches before testing

Fky
  • 2,133
  • 1
  • 15
  • 23