Skip to main content
added 143 characters in body
Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

From Drupal.org:

$form['element_id'] = array(
  '#type' => 'checkboxes',
  '#options' => array(1 => "One", 2 => "Two", 3 => "Three"),
  '#default_value' => array(1, 3),
);

Default value is set as an array representing keys of selected options.

Looking at the code in your question, problem is with spelling. you are setting '#deafult_value' when you want to set '#default_value'.

From Drupal.org:

$form['element_id'] = array(
  '#type' => 'checkboxes',
  '#options' => array(1 => "One", 2 => "Two", 3 => "Three"),
  '#default_value' => array(1, 3),
);

Default value is set as an array representing keys of selected options.

From Drupal.org:

$form['element_id'] = array(
  '#type' => 'checkboxes',
  '#options' => array(1 => "One", 2 => "Two", 3 => "Three"),
  '#default_value' => array(1, 3),
);

Default value is set as an array representing keys of selected options.

Looking at the code in your question, problem is with spelling. you are setting '#deafult_value' when you want to set '#default_value'.

Source Link
Mołot
  • 21.9k
  • 8
  • 59
  • 112

From Drupal.org:

$form['element_id'] = array(
  '#type' => 'checkboxes',
  '#options' => array(1 => "One", 2 => "Two", 3 => "Three"),
  '#default_value' => array(1, 3),
);

Default value is set as an array representing keys of selected options.