Using forms and templates and _submit callback I'm trying to wrap my head around the process of creating a form and handling the submitted data using x_submit().

I start by having a form callback:

function world_form(&amp;$form_state) {

  // if ($form_state['post']) { drupal_set_message("Solved!"); }

  $forms['fieldset_options'] =
    array('#type' =&gt; 'fieldset',
          '#title' =&gt; t('Options'),
          '#collapsible' =&gt; FALSE,
          '#collapsed' =&gt; FALSE);

  $forms['fieldset_options']['tags'] =
    array('#type' =&gt; 'item', '#title' =&gt; 'Simple stuff');

  $forms['fieldset_options']['checkbox1'] =
    array('#type' =&gt; 'checkbox', '#title' =&gt; t('Solve world problems'));

  $forms['fieldset_options']['submit'] =
    array('#type' =&gt; 'button', '#button_type' =&gt; 'submit', '#value' =&gt; 'Go!');

  // $forms['submit'] = array('#type' =&gt; 'submit', '#value' =&gt; 'Go!');

  return $forms;
}


So I specify a theme callback, which takes me to a file world.tpl.php in which I do:

print drupal_get_form('world_form');


which invokes my form callback. So far so good. Now the problem I have is that I want to handle when this form is submitted (more specifically, I want the value of the checkbox when it is checked). I read a lot of documentation and most mention the world_form_submit function. So I create one like this:

function world_form_submit($form, &amp;$form_state) {
  drupal_set_message("Posted!");
}


But after I've done that the function isn't called. However if I instead use the line which is commented out in my form function and comment out the '#type' =&gt; 'button' field it DOES get called and I can now access the checkbox state, however the problem I have now is that the form is not updated with the state of the checkbox (I.e. if I check the box and submit I get to the same page but the box is no longer checked).

So my questions are:


Why isn't the _submit callback called when I use a "regular" submit button? Do I have to use the $forms['submit'] way?
If I do get the _submit callback called, can I still update my form to reflect what it was before I submitted, and
How can I get the checkbox state in my world.tpl.php file? Say I want to print something if it is checked.


Thank you for your time.
Many questions here:


Your form function function should return the form array and doesn't need an argument unless you need it for something specific.
You should at least have an element of type 'submit' (not button) in your form.
Chances are good your submit function will get called if you implement it this way.
If the form fails validation, FAPI will restore it to the values submitted, keeping what was typed by the user.
You shoudn't try to embed business logic in your template, but rather in your module and/or a preprocess function.