creating a quality product with an involved client

Call us on
0783 497 8652

Adding Reset button to drupal forms

Using the hook_form_alter function one can add a reset button to drupal forms.

Replace yourModuleName in the function with your module name..

See drupal.org for creating modules or you can add the function to one of your existing modules. If you would like to add a reset button for the webforms module replace the if line with this

 if ((strpos($form_id, 'webform_client_form_') === 0) || (strpos($form_id, 'contact_mail_page') === 0)) {

 * Implementation of hook_form_alter().
function yourModuleName_form_alter(&$form, $form_state, $form_id) {
    if ((strpos($form_id, 'contact_mail_page') === 0)) {
        $form['reset'] = array(
          '#value' => '<input class="form-button" type="reset" value=" Reset " />',
          '#weight' => 1001,