Closed (works as designed)
Project:
Webform
Version:
7.x-3.15
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
28 Jul 2008 at 15:58 UTC
Updated:
21 Nov 2015 at 09:08 UTC
Jump to comment: Most recent
Comments
Comment #1
quicksketchI personally despise reset buttons. If a particular client is requesting it, I'd suggest that you use a custom module and use hook_form_alter() to add a reset button to all webform forms.
Comment #2
luco commentedyeah, I really don't see the point either. but like I said....... clients do. u know, the web isn't always as we wish.
anyway I was looking for something more newbie friendly. or perhaps you could point me to an article that explains further?
Comment #3
traviscarden commentedGranted we may not see a compelling reason to use such and such a feature of HTML, but insofar as it exists--and in this case is a common form element, and Webform is meant to simplify the creation of forms--it looks like an oversight to omit it. But suppose a person were filling out a form and decided that they wanted not to leave the form but merely to start over. A page refresh would be superfluous to that end. A reset button would be the most logical solution. Besides, as Luciano points out, sometimes "the client just wants one". And who wants to tell their client, "I'm sorry, a 'Reset' button is complicated functionality in Drupal. I'd have to bill you a couple extra hours to learn to write a custom module to programmatically add one (and then you won't be able to change it through the web interface)"? All that to say that I too would like the ability to add a "reset" button. But, lest I seem to harshly critical, I would like to say that Webform is a great module, and I really appreciate all the work that's gone into making it so useful--even if I have a little different perspective on this particular, little issue. :) Thanks.
Comment #4
quicksketchI'm still against this enough that I don't think a single checkbox for "Include a Reset Button" is worth including in the UI, when 99% of people will never want the option (though they might turn on the option even when they don't want or understand it). Adding a reset button through a form alter is not a complicated task.
Interestingly, Drupal in general has found a reset button so useless that the FAPI doesn't even have a built-in #type for it. Hence why you have to just print the straight HTML.
Comment #5
dave the brave commentedYou can add a reset button pretty simply by adding a Markup field with
<input class="form-button" type="reset" value="Reset" />.It works just fine, and if you need it positioned after the submit button, just use css to position.
Comment #6
quicksketchAs I've said above, there are no plans to implement this in Webform.
Comment #7
kotnik commentedDrupal 6 version of this hook is:
Comment #8
Lucience commentedThank you Dave!
Comment #9
gopisundar commented<?php
function reset_button_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;'),
);
}
}
this works for drupal 7..
Comment #10
luco commented@quicksketch, I've reopened this issue just to ask you: if someone were to write a patch for Webform that included a reset button component, would you be willing to integrate it into your module?
regards
Comment #11
luco commentedComment #12
quicksketchNo probably not. Though if you want to make it a component, you can easily keep that in a separate module by using Webform's hook_webform_component_info().
Comment #13
luco commentedit just hit me! there is a simpler way to go about this.
simply add a markup field with
<input type="reset" value="Reset" id="reset-button">at the end, then style it. ta-daaa! ;)Comment #14
gopisundar commented@luco
By doing this you can bring the reset button in webform but you cant arrange the button with submit button. the code i posted will do that too.
Comment #15
luco commented@gopisundar sure! my solution is heavier on CSS, but lighter on PHP. that's all. ;)
Comment #16
gopisundar commented@luco
Ya thats right. i gave a suggestion:)
Comment #17
technikh commented#9 Worked like a charm. Thanks gopisundar!
Comment #18
thetpaing commentedThanks gopisundar ......
Comment #19
谢艳 commentedCurrently, i am using the way provide from #5, it works like a charm.haha
Comment #20
rreiss commented#13 Is the best (and easiest) answer in my opinion.
Comment #21
rcodina+1 to solution explained in #13. Thanks!!!
Comment #22
jabastin arul commentedYou can add a reset button pretty simply by adding a Markup field with .
But its not an best pratice. My suggestion is you may alter the form like this...
function _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;'),
);
}
}