Set Custom value in checkbox
You can try adding '#return_value':

foreach($my_array as $key =&gt; $value) {
      $form['custom_field'] = array(
        '#type' =&gt; 'checkbox',
        '#return_value' =&gt; $key,
        '#title' =&gt; $value,
        '#default_value' =&gt; variable_get('custom_field'),
      );
    }