Checkboxes Defaulting to Selected When Not Desired This is going to be sound like a real stupid question, but for the life of me I don't know how to fix it. I have inherited some code that I need to maintain, and the issue I am experiencing is that a form containing checkboxes is displayed, and they are always all selected. The code for the checkboxes is as follows:

$license_result = db_select('licenses')
  -&gt;fields('licenses', array('code', 'name'))
  -&gt;execute();

foreach ($license_result as $license) {
  $licenses[$license-&gt;code] = htmlspecialchars($license-&gt;name);
}
$selected_licenses = array();
return array(
  'selected_licenses' =&gt; array(
    '#type' =&gt; 'checkboxes',
    '#title' =&gt; t('Licenses to Display'),
    '#description' =&gt; t('Select which licenses the student should be able to select'),
    '#options' =&gt; $licenses,
    '#default_value' =&gt; $selected_licenses,
  ),
);


I though that by having an empty array for #default_value would deselect all checkboxes. Am I reading the form API wrong in this regard? Eventually I would like to set the default values but right now I want to make sure they start off as unselected.

Thanks.
I think you have to set the value in each checkbox, so probably this would be it :

foreach ($license_result as $license) {
  $licenses[$license-&gt;code] = htmlspecialchars($license-&gt;name);
  $licensevalues[$license-&gt;code] = 0;
}
$selected_licenses = array();
return array(
  'selected_licenses' =&gt; array(
    '#type' =&gt; 'checkboxes',
    '#title' =&gt; t('Licenses to Display'),
    '#description' =&gt; t('Select which licenses the student should be able to select'),
    '#options' =&gt; $licenses,
    '#default_value' =&gt; $licensevalues,
  ),
);