Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form reset/clear #2504

Closed
beggiatom opened this issue Jul 2, 2015 · 3 comments
Closed

Form reset/clear #2504

beggiatom opened this issue Jul 2, 2015 · 3 comments

Comments

@beggiatom
Copy link

Hi, I have a number of forms each with a different ID and a CLASS equal.
In version 1.x when I called the reset method on all forms of the page, the values returned to its original state, but with version 2.0.0, each field is cleared of any value including fields that had a value already set.

Init form:

<form class="reply-form" id="form_1">
   <input type="hidden" name="post_id" value="1"/>
   <textarea name="message"></textarea>
</form>
<form class="reply-form" id="form_2">
   <input type="hidden" name="post_id" value="2"/>
   <textarea name="message"></textarea>
</form>

javascript reset

$('form.reply-form').each(function() {
    $(this).form('reset');
})

In 1.x version all good they return as "init form", while in 2.0.0 version forms become

<form class="reply-form" id="form_1">
   <input type="hidden" name="post_id" value=""/>
   <textarea name="message"></textarea>
</form>
<form class="reply-form" id="form_2">
   <input type="hidden" name="post_id" value=""/>
   <textarea name="message"></textarea>
</form>

It is as if I had called the clear method.

@jlukic jlukic added this to the 2.0.x milestone Jul 2, 2015
@jlukic
Copy link
Member

jlukic commented Jul 6, 2015

Hi, for form to correctly reset values you will have to call $('.ui.form').form(); on page load. The first time it is invoked it will save the default values to return to with reset.

@jlukic
Copy link
Member

jlukic commented Jul 6, 2015

I've gone ahead and changed the default reset behavior to "do nothing" in this case, as oppose to abnormally clearing values.

@jlukic
Copy link
Member

jlukic commented Jul 6, 2015

I've also added a new note to docs explaining this limitation.

@jlukic jlukic closed this as completed Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants