Programmatically created list_boolean checkbox field value won't get saved I've added a lot of fields and field instances via a custom module to some prepared content types. field_create_field() and field_create_instance() work like a charm, not a single error. Every field then works as expected, EXCEPT for the checkbox field.

It appears at the right place, has the right label, BUT when it comes to node saving the checked checkbox simply won't save. Next time I edit the node it's unchecked again, no value got written to the database. What do I miss here?

$field = array(
  'field' =&gt; array(
    'field_name'  =&gt; 'MYFIELD',
    'label'       =&gt; 'Set as default',
    'type'        =&gt; 'list_boolean',
  ),
  'instance' =&gt; array(
    'field_name'  =&gt; 'MYFIELD',
    'entity_type' =&gt; 'node',
    'bundle'      =&gt; 'MYBUNDLE',
    'label'       =&gt; 'Set as default',
    'widget'      =&gt; array(
      'type'      =&gt; 'options_onoff',
      'settings'  =&gt; array(
        'display_label' =&gt; TRUE,
      ),
    ),
    'display'     =&gt; array(
      'default'   =&gt; array(
        'label'   =&gt; 'hidden',
        'type'    =&gt; 'hidden',
      ),
    ),
  ),
);

field_create_field($field['field']);
field_create_instance($field['instance']);
Thanks @Clive, all that was missing were 'allowed_values' in $field['field]:
$field = array(
  'field' =&gt; array(
    'field_name'  =&gt; 'MYFIELD',
    'label'       =&gt; 'Set as default',
    'type'        =&gt; 'list_boolean',
    // It's mandatory to add at least two empty values here,
    // Drupal will do the rest then:
    'settings'    =&gt; array(
      'allowed_values' =&gt; array(
        '',
        '',
      ),
    ),
  ),
  'instance' =&gt; array(
    'field_name'  =&gt; 'MYFIELD',
    'entity_type' =&gt; 'node',
    'bundle'      =&gt; 'MYBUNDLE',
    'label'       =&gt; 'Set as default',
    'widget'      =&gt; array(
      'type'      =&gt; 'options_onoff',
      'settings'  =&gt; array(
        'display_label' =&gt; TRUE,
      ),
    ),
    'display'     =&gt; array(
      'default'   =&gt; array(
        'label'   =&gt; 'hidden',
        'type'    =&gt; 'hidden',
      ),
    ),
  ),
);

You simply have to declare empty On/Off values. Which may not seem too obvious, but logical at least since when you create options_onoff checkbox from the backend there's written:

On value [_____] If left empty, &quot;1&quot; will be used.
Off value [_____] If left empty, &quot;0&quot; will be used.