Drupal 7 – Add reset button to Webform

The Drupal Webform does not have the reset button by default. If you want to have one, you can create custom module to alter the form.

function <module>_form_alter(&$form, $form_state, $form_id) {
  if (strpos($form_id, 'webform_client_form_') === 0 || ($form_id=='user_register_form')) {
    $form['actions']['reset'] = array(
      '#type' => 'button',
      '#value' => t('Reset'),
      '#weight' => 100,
      '#validate' => array(),
      '#attributes' => array('onclick' => 'this.form.reset(); return false;'),
    );
  }
}

 

The above code will add the reset button to all Webform as well as the user registration form.

Done =)

Reference: Drupal Webform – ‘reset’ button

Advertisements

3 thoughts on “Drupal 7 – Add reset button to Webform”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s