Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

[Agency] Reset Button on Contact form

first-time form

Solved by pamtbaau View solution

Started by barnabécane 5 years ago · 6 replies · 982 views
5 years ago

Hi there !

While (still) trying to get a working contact form, I read one more time the https://learn.getgrav.org/17/forms/forms/example-form
And there is an additional button to reset the form, witch I found is a useful idea !
Unfortunately, this does not work in the Agency theme, or is it my stuff that has the problem ?

Any clue of how to make it work ?

here is what I put in my grav/user/pages/01.home/_contact/form.md

although, this reset button does not react when pointer is over ...

YAML
    buttons:
        - type: submit
          classes: "btn btn-primary btn-lg"
          value: Envoyer
        - type: reset
          classes: "btn btn-primary btn-lg"
          value: Effacer

Any help will be appreciated ^^

EDIT:
in fact, it does work but in certain condition and certainly not after having submit a valid form ...

last edited 06/10/21 by barnabécane
5 years ago

@citoyencandide, Apart from the issue you are experiencing, you might consider if a Reset button is good UX.

According to MDN on <input type="reset">

You should usually avoid including reset buttons in your forms. They're rarely useful, and are instead more likely to frustrate users who click them by mistake (often while trying to click the submit button).

About the issue:
I can reproduce the behaviour you are observing on a fresh install, using theme Quark and the demo Contact form from the docs.

You might consider opening an issue on github.com/getgrav/grav-plugin-form.

5 years ago Solution

@citoyencandide, Since I never used a reset button, the observed behaviour of the Reset button didn't ring a bell to me...

After some Googling it appears to be the standard behaviour of the <input type="reset"> button.

According to MDN on <input type="reset">:

<input> elements of type reset are rendered as buttons, with a default click event handler that resets all of the inputs in the form to their initial values [emphasis mine].

Since the form has been submitted and the refreshed page contains the values in the field, these values are the initial values and hence will not be cleared by reset.

To clear the fields after a submit, the action reset: true can be used.

You might want to close the issue at Github.

5 years ago

OK, closed.

In terms of UX, isn't changing the color of the button enough to avoid user clicking the wrong button ?

(collateral question : how do I change this color?)

5 years ago

@citoyencandide,

In terms of UX, isn’t changing the color of the button enough to avoid user clicking the wrong button ?

I think I would first ask myself what the use-case might be that makes adding a Reset button valuable.

last edited 06/11/21 by pamtbaau
5 years ago

you're right : it's not because it is available that you need it ...

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1144 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago