Repository: carpentries/amy

Issue:
Change the way "reset" buttons work
- Rename button from "reset" to "cancel".
- Make the button white instead of red.
- Redirect back to the last page in history.



Discussion:
Shouldn't a `Cancel` button also redirect back to the last page in history? Most `Cancel` buttons work that way.

I would suggest renaming it to `Discard all changes`.

@narayanaditya95 , I'd stick with "cancel", because it's well understood by most people that "cancel" is the safe option when they get lost (thanks to cancel/ok and cancel/no/yes dialogs). I'd be afraid to click any button that includes "discard" verb.

The change you suggest would then fail to solve the issue @maneesha raised at #881 . Are you sure we want to change the functionality of the `Reset` button to a `Cancel` button?

@narayanaditya95 , I don't understand, I think that the change I propose does solve the issue. @maneesha wrote in #881:

>  I'd also like to see a "cancel" button so that any changes accidentally made while in editing mode are not saved.

This is exactly what I propose.

My bad. 


Resolving patch:
diff --git a/pydata/forms.py b/pydata/forms.py
--- a/pydata/forms.py
+++ b/pydata/forms.py
@@ -21,7 +21,7 @@ class BaseModelAddFormSet(forms.models.BaseModelFormSet):
     validate_min = False
 
     helper = BootstrapHelper(
-        form_tag=False, add_submit_button=False, add_reset_button=False)
+        form_tag=False, add_submit_button=False, add_cancel_button=False)
 
     def __init__(self, *args, **kwargs):
         # Override the default form helper
diff --git a/workshops/forms.py b/workshops/forms.py
--- a/workshops/forms.py
+++ b/workshops/forms.py
@@ -3,7 +3,7 @@
 from captcha.fields import ReCaptchaField
 from crispy_forms.bootstrap import FormActions
 from crispy_forms.helper import FormHelper
-from crispy_forms.layout import Layout, Div, HTML, Submit, Reset, Field
+from crispy_forms.layout import Layout, Div, HTML, Submit, Button, Field
 from crispy_forms.bootstrap import AccordionGroup, Accordion
 from django import forms
 from django.core.exceptions import ValidationError
@@ -40,7 +40,7 @@ def __init__(self,
                  wider_labels=False,
                  add_submit_button=True,
                  add_delete_button=False,
-                 add_reset_button=True,
+                 add_cancel_button=True,
                  additional_form_class='',
                  form_tag=True,
                  display_labels=True,
@@ -103,9 +103,11 @@ def __init__(self,
                 css_class='btn-danger',
                 style='float: right;'))
 
-        if add_reset_button:
-            self.add_input(
-                Reset('reset', 'Reset', css_class='pull-right btn-danger'))
+        if add_cancel_button:
+            self.add_input(Button(
+                'cancel', 'Cancel',
+                css_class='btn-default pull-right',
+                onclick='window.history.back()'))
 
         self.form_class = 'form-horizontal ' + additional_form_class
 
@@ -285,7 +287,7 @@ class SearchForm(forms.Form):
                                      required=False,
                                      initial=True)
 
-    helper = BootstrapHelper(add_reset_button=False)
+    helper = BootstrapHelper(add_cancel_button=False)
 
 
 class DebriefForm(forms.Form):


Test patch: