Simple way to toggle a reset of all confiforms fields
Asked by Jason Walsh:

Looking for a simple way for an end user to toggle a reset of all fields on a form. I know that the Confiforms rule "reset" will achieve this to an extent, however, I'd love to have a JavaScript driven button float at the bottom of the form so the end user has easy access to a reset function. Is this doable? Any help is appreciated, thanks!


Answers:
author: Alex Medved _ConfiForms_
body: Hi Jason!

Great question!

Well, you can easily add anything you want into the "form dialog initialization", including something like an "extra button" with custom function

See the quick demo below

<http://recordit.co/Efi5wlcetE>

Hope it helps

Alex

comments: author: Jason Walsh
body: This is exactly what I was looking for. As for the function to reset the field values, my JS is far from excellent, how would I go about doing that in the function?


author: Alex Medved _ConfiForms_
body: A lot depends on what field you want to reset...

Could be as easy as (for many field types it works)

```
AJS.$('#' + formId).find('#i_mytext').val('');
```

(where "mytext" is my text field value on a form)

And much more complicated is to reset "drawing canvas" in ConfiForms, and some other field types...


author: Jason Walsh
body: This is perfect! Implemented and works as intended. Thanks so much Alex!


author: Loren
body: [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) I followed this solution however it is hiding the entire form and now I am only seeing the paragraph above the form and form isn't showing on the page.

I am doing it as a Rendering Form as Embedded. Is there a solution that works with the rendering form as embedded where I can still add a reset button?

I did include the code you used in the example at the bottom within the ConfiForms field definition box.

comments: author: Alex Medved _ConfiForms_
body: Sorry, hard to tell anything without seeing what you have implemented.

If you follow the demo precisely then you will get the results demonstrated


author: Loren
body: Let me provide some more detail then to show how I built my form.

I have at the top ConfiForms (FormView Registrations Control)

ConfiForms Form Name:TARF

Rendering Form as: Embedded

Label for Registration Button:Submit

Override Label for Save Button: Submit

Override Label for form Close Button: Reset

Message to show after a record has been created: Your Form has been submitted

Execute custom Javascript function after the form is loaded: myCustomScript(formId);

Within the Confiforms Form Registrations Controls

I have Confiforms fields over 10 of them including Title, Type of Request, Product, etc.

Separate from the above below it

I have ConfiForms Form definition with over 10 of them including Title, Type of Request, Product, etc.

And underneath that I have the HTML macro that has the javascript listed in your demo.

The issue I'm having is when I put in the information I no longer see ConfiForm fields on the confluence page after I publish it they go away and are becoming hidden after adding Execute custom Javascript function after the form is loaded myCustomScript(formId)

The ConfiForm fields/request form only displays everything when I select rendering for as a button. It hides. The ConfiForm fields/request form on the page when I select rendering for embedded.

But I need to be able to see the request form on the page and then at the bottom submit button and reset button when the user goes to the page.


author: Alex Medved _ConfiForms_
body: Same example, as originally posted, but with the embedded form

<http://recordit.co/HpwBNR3Zkm>

As noted earlier - works absolutely the same way

Alex


author: Loren
body: Thanks a lot Alex. I do now see a Reset button next to Submit on my form in Confluence. After following your embedded demo.

But one more question

```
AJS.$('#' + formId).find('#i_mytext').val('');

```

As you mentioned here somewhat higher on this page and in this example . Now with my reset button how do I get it to for example reset ConfiForm field definition Field Name Apps Field Label Software Field Type Drop down

Connected to it

confiform field

field name Apps

Override Label Software Apps

Where the reset button resets the Confiform fields.

Thanks


author: Alex Medved _ConfiForms_
body: You can either use/add the JS code as in the demo

```
AJS.$('#' + formId).find('#i_mytext').val('');
```

Changing *mytext* to match your field names or by using our APIs/code

<https://wiki.vertuna.com/display/CONFIFORMS/JavaScript+functions>

```
function?cfSetValue(formId, fieldName, fieldValue, isAdvanced = false)
```

Rewriting the example above with mentioned functions

```
cfSetValue(formId, 'mytext', '');
```

Resetting the value of an advanced dropdown should be done via

```
cfSetValue(formId, 'mydropdownfield', '', true);
```

Alex


author: Loren
body: Thanks again Alex. The JavaScript solution worked on my form for fields with drop downs and the fields that are text area (the reset button is working for that) except it's not working for the field names that are field type multi select or text box group. Do I need to add something additional for multi select and text box group field types for the javascript solution?


author: Alex Medved _ConfiForms_
body: Hi

Try with "advanced" flag set to true

```
cfSetValue(formId, 'mydropdownfield', '', true);
```

for multi-select fields.

Not sure though what is a "text box group" field

Alex


author: Loren
body: I meant to say field type Checkbox Group not Text box group.

    <script type="text/javascript">function my CustomScript(formId) {AJS.$('#' + fomdId).find('.save-cf-btn').after('<button type="button"` class="aui-button cf_reset_btn" style="margin=right: 10px;">Reset</button>');AJS.$('#' + formID).find('.cf_reset_btn').click(function() { AJS.$('#' + formID).find('#i_totr').val(''); AJS.$('#' + formID).find('#i_title').val('');  });}

    function cfSetValue(formId, 'my multiselect field', '',
    true);
      });}
    </script)

The above code is working in resetting the drop down fields and text fields (with the reset button) but its not working in resetting the multi select and checkbox group fields. I tried doing the above. What do I need to change regarding cfSetValue function, for this to work?


author: Loren
body: Your solution you listed on October 15th is now working on my form. Thanks again Alex.


author: Elena Rodriguez
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

I was looking to something similar to this 'reset fields' feature, and I found your solution, that I'm trying to replicate with no luck

I copied your exact solution, but I cannot see the Reset button appearing in the form.

Could you help me find what I'm doing wrong??

This is what I created:  
![Confiforms config.png](https://community.atlassian.com/t5/image/serverpage/image-id/271588iFF718B157E7FCA31/image-size/large?v=v2&px=999 "Confiforms config.png")  
And as you can see, the reset button is not appearing in the form:  
![NoResetButton.png](https://community.atlassian.com/t5/image/serverpage/image-id/271589iA38C9A7619447DDB/image-size/large?v=v2&px=999 "NoResetButton.png")  

Thanks


author: Alex Medved _ConfiForms_
body: Hi,

Have a look more carefully what you have in your script... it is full on typos

fomdId

formid

to name a few... It is just a broken script

Alex


author: Elena Rodriguez
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

Of course... sorry for that. I fixed the typos and also removed the newline feeds and it's working fine for me

I have another question:

I have a form with a voting control field. Then I have created a table view to show the records and allow people to vote.  
![votingControl.png](https://community.atlassian.com/t5/image/serverpage/image-id/271756iDF003E297E6E6005/image-size/large?v=v2&px=999 "votingControl.png")  
I know there Voting control allows to remove votes one by one, but... is there anyway that I can add a button (or something) to clear all votes from all records?  

Thanks a lot


author: Alex Medved _ConfiForms_
body: Makes sense to open a new question (easier for others to find relevant contents, cleaner discussion, clearly visible answer), but here is what you can do:

<http://recordit.co/3TmvSEcbtz>

Alex


Tags: confiforms

confluence-server

server