How to keep checkbox checked after form submit I am trying to keep checkbox "checked" after form submit and page load. I have following simple code from .module file.

    &lt;?php

function my_module_menu() {
  $items = array();

  $items['examples/my_module'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' =&gt; 'Example Form', //page title
    'description' =&gt; 'A form to mess around with.',
    'page callback' =&gt; 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' =&gt; array('my_module_form'), //put the name of the form here
    'access callback' =&gt; TRUE
  );
  return $items;
}

function my_module_form($form, &amp;$form_state) {

$form['terms'] = array(
        '#type' =&gt; 'checkbox',
        '#title' =&gt; t('Your checkbox'),
    );
  $form['submit_button'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Click Here!'),
  );

  return $form;
}

function my_module_form_submit($form, &amp;$form_state) {
  $form['terms']['#default_value'] = 1;
  }

?&gt;


How can I achieve this?
First you need to specify #default_value to your element, Then if you are going to save your data in some place, then load it and use it as your element default_value, if you are not going to save it then you can use form_state on that but remember to set $form_state['form_rebuild'] as TRUE in submit handler, a sample code will be like this :

function my_module_form($form, &amp;$form_state) {

  $form['terms'] = array(
    '#type' =&gt; 'checkbox',
    '#title' =&gt; t('Your checkbox'),
    '#default_value' =&gt; isset($form_state['values']['terms']) ? $form_state['values']['terms'] : array(),
  );
  $form['submit_button'] = array(
   '#type' =&gt; 'submit',
   '#value' =&gt; t('Click Here!'),
  );

  return $form;
}
function my_module_form_submit($form, &amp;$form_state) {
  $form['terms']['#default_value'] = 1;
  $form_state['rebuild'] = TRUE;
}