Single on/off checkbox default value not work I have a boolean user profile field which is single on/off checkbox, says 'field_user_flag'. Its On value is 1 and Off value is 0. But I could not set #default_value = 1 from hook_form_alter to save "1" into its table field_data_field_user_flag and field_revision_field_user_flag.

When it is 0 and unchecked in user/*/edit, I would like to set it to 1 and checked. Thus, I did it in my hook_form_alter as below.

$form['field_user_flag']['#default_value'] = 1;
$form['field_user_flag']['#attributes'] = array('checked' =&gt; 'checked');


But, it did not work. I created the field in account settings (admin/config/people/accounts/fields/) without using Profile 2 module.
I tested it and worked for me:  

$form['field_user_flag'][LANGUAGE_NONE]['#default_value'] = 1;


You can also set a default value of this field (in field settings in field managment).