I have form with check boxes. The user checks the boxes and hits the submit button. If validation fails an error message is displayed. I also want all of the user’s checks to be cleared so they can try again. Here’s my code, but it does not clear the checks? Thanks.
/** * Defines a form. */ function my_form($form, &$form_state) { $form['alerts'] = array( '#type' => 'checkboxes', '#options' => $options, ); // the rest of my form if (isset($form_state['clear_checkboxes'])) { $form_state['values']['alerts'] = array_fill(0, count($form_state['values']['alerts']), 0); } return $form; } /** * Form validator. */ function my_form_validate($form, &$form_state) { // if validation fails set error message $form_state['rebuild'] = TRUE; $form_state['clear_checkboxes'] = TRUE; }