I need the checkbox to be checked by default. Below is my code, notice the 'default_value'
under the settings array.
$field_instance = array( 'field_name' => $fielddef['field_name'], 'type' => 'list_boolean', 'entity_type' => 'user', 'bundle' => 'user', 'label' => t($opts['label']), 'description' => t($opts['description']), 'required' => FALSE, 'widget' => array( 'type' => 'options_onoff', 'weight' => 10, ), 'settings' => array( 'allowed_values' => drupal_map_assoc(range(0,1)), 'default_value' => array(array('value' => 1)) ) ); field_create_instance($field_instance);
I have tried using ‘default_value’ in the $field_instance
array, I’ve also tried 'default_value_function'
without success. I feel like I’m close on this, what am I missing? Thanks!
Also, I am running Drupal 7.23 as shown on my Status Report. I asked this question earlier on SO, but no reply so I moved it here: https://stackoverflow.com/q/19772646/988355