I have a content type that has a boolean field (checkbox) that editors need to always re-check on saving a new revision, if they want the value to still be true
. Otherwise, it would be saved as false
.
I'm using a hook_form_node_form_alter
to modify the $form
before the page is shown to the Editor.
public function my_module_form_node_form_alter(&$form, &$form_state, &$form_id)
{
$form['field_my_boolean_field']['#value'] = 0;
}
I've tried something similar to the above and have also tried #checked
and #default_value
in place of #value
but nothing seems to work. The checkbox always renders checked (as it is saved in the database). How can I uncheck this boolean field when the form is rendered? Note that I do not want to change the actual value of the field for this node, just make it unchecked in the UI when the form for this content is shown.