How to make a reset form button without type 'markup'? My situation:

I built a form with FAPI. I display the results in a table like this:

function grap_contact_repository_form_submit($form, &amp;$form_state) {
  ...
  $form_state['results_table'] = array('#markup' =&gt; grap_contact_repository($matches));
  $form_state['rebuild'] = TRUE;
}


The grap_contact_repository function returns a theme_table.

My problem:

Because of the results_table that already uses a #markup type, I can't build a reset button for my form using '#type' =&gt; 'markup' too. (Because all the results table will be clickable too).

I'm looking for an alternative to make this button work. I tried this:

$form['clear'] = array(
  '#type'       =&gt; 'button',
  '#value'      =&gt; 'Réinitialiser',
  '#attributes' =&gt; array('onclick' =&gt; 'this.form.reset();'),
);


or this: (http://www.blue-bag.com/blog/drupal-form-api-reset-button)

  $form['reset'] = array(
    '#type' =&gt; 'button',
    '#button_type' =&gt; 'reset',
    '#value' =&gt; 'Réinitialiser',
    '#validate' =&gt; array(),
    '#attributes' =&gt; array(
      'onclick' =&gt; 'this.form.reset(); return false;',
    ),
  );


But it doesn't work. The onclick works if I put another JavaScript like alert. I have nothing in my JS errors console.

Does someone have an idea to make it work?

Thanks a lot :-)
Type should be reset, not button.
  
  http://www.w3schools.com/tags/att_button_type.asp


You right, there is no such type. I was able to get this working with 2 submit buttons and return false (similar to your original implementation).

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

  $form['name']=array(
    '#type'=&gt;'textfield',
    '#title'=&gt;t('Enter your name'),
    '#description'=&gt;t('Your first name goes here')
    );

  $form['submit_button1'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Submit',
    );  

  $form['reset_button'] = array(
    '#type' =&gt; 'submit',    
    '#value' =&gt; 'Reset',
    '#validate' =&gt; array(),
    '#attributes' =&gt; array(
        'onclick' =&gt; 'this.form.reset(); return false;',
        ),
      );

  return $form;
}


If it still doesn't work there is this alternative solution: How to reset specific form elements