How to correctly get Form API single checkbox value variable from database? I created an additional_settings fieldset for node type forms that holds a single checkbox:

$form['MY_SETTING']['enabled'] = array(
  '#type' =&gt; 'checkbox',
  '#title' =&gt; t('Enable'),
  '#default_value' =&gt; variable_get('MY_SETTING_' . $form['#node_type']-&gt;type, FALSE),
);


When I check the checkbox and save the node type form the value gets stored like that: MY_SETTING_MY_NODETYPE[0] = 'enabled'. The #default_value only understands TRUE and FALSE and doesn't work with enabled. I've sneaked in other modules (p.e. comments module) and have seen that they solved that with constants. But how to apply a constant in that form logic and let it be saved to the database?
You could use constants in place of string literals, sure, but that's not related to the issue you're having. That's simply a matter of converting the statement you already have to a boolean.

Which is as easy as:

$bool_enabled = variable_get('MY_SETTING_' . $form['#node_type']-&gt;type, 'disabled') == 'enabled';
$form['MY_SETTING']['#default_value'] = $bool_enabled;


Incidentally, the string "enabled" evaluates to TRUE in PHP, so it's not possible for it "not to work with enabled", it's just that 'disabled' also evaluates to TRUE, so you won't ever see a falsey value.

Personally I think the simplest solution is store the variable as an integer, 1 or 0. Then you can just assign it straight to the form element and let PHP's implicit integer -> boolean conversion take over. That's how all core (and contrib, that I've seen) modules handle it.