Skip to main content
added 261 characters in body
Source Link
Shabir A.
  • 2.9k
  • 13
  • 25

You can use form_state instead of form in your submit handler and use default_value of check box in your form alter

$form['account']['checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => 'Test check',
    '#default_value' => 0,
   );

and then your submit handler will go like this

function module_simplenews_unsubscribe($form, &$form_state) {

  if ($form_state['values']['checkbox'] == 0) {
    drupal_set_message(t("You are checked"));
  }
 if ($form_state['values']['checkbox'] == 1) {

    drupal_set_message(t("You are unchecked"));
  }

Use debug tools for proper index of form_state for checkbox.

You can use form_state instead of form in your submit handler

function module_simplenews_unsubscribe($form, &$form_state) {

  if ($form_state['values']['checkbox'] == 0) {
    drupal_set_message(t("You are checked"));
  }
 if ($form_state['values']['checkbox'] == 1) {

    drupal_set_message(t("You are unchecked"));
  }

Use debug tools for proper index of form_state for checkbox.

You can use form_state instead of form in your submit handler and use default_value of check box in your form alter

$form['account']['checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => 'Test check',
    '#default_value' => 0,
   );

and then your submit handler will go like this

function module_simplenews_unsubscribe($form, &$form_state) {

  if ($form_state['values']['checkbox'] == 0) {
    drupal_set_message(t("You are checked"));
  }
 if ($form_state['values']['checkbox'] == 1) {

    drupal_set_message(t("You are unchecked"));
  }

Use debug tools for proper index of form_state for checkbox.

Source Link
Shabir A.
  • 2.9k
  • 13
  • 25

You can use form_state instead of form in your submit handler

function module_simplenews_unsubscribe($form, &$form_state) {

  if ($form_state['values']['checkbox'] == 0) {
    drupal_set_message(t("You are checked"));
  }
 if ($form_state['values']['checkbox'] == 1) {

    drupal_set_message(t("You are unchecked"));
  }

Use debug tools for proper index of form_state for checkbox.