Foren

Clean all fields button

Maximiliano Chiesa, geändert vor 11 Jahren.

Clean all fields button

Junior Member Beiträge: 47 Beitrittsdatum: 20.07.12 Neueste Beiträge
Hi! I started learning Liferay a couple of days ago, I'm developing a new portlet for a portal and a I have a Form in which I need a "Clear" button that resets all the fields of the form to their default values.
This is my form at the moment, the button "Clean" would call the action to reset the rest of the fields.

<aui:form action="<%= generateValues %>" method="post">

<aui:select name="depts" label="Depts."> ....... </aui:select>

<aui:select name="type" label="Type"> ....... </aui:select>

<aui:input label="pattern" name="padron" type="text"/>
<br/>

<aui:button type="submit" value="View information" />
<aui:button type="cancel" value="Clean" />
<br/>
</aui:form>


What's the best way of making this?

Thanks!
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: Clean all fields button

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Create a javascript to initialize settings and have button call this method onClick().

<aui:button onClick="<%= initForm() %>" type="cancel" value="Clean" />
Maximiliano Chiesa, geändert vor 11 Jahren.

RE: Clean all fields button (Antwort)

Junior Member Beiträge: 47 Beitrittsdatum: 20.07.12 Neueste Beiträge
This is how I finnaly solved this:

<aui:button type="cancel" value="Limpiar" onclick="this.form.reset()" />

Not sure if it's the best solution but it worked emoticon

Thanks!
thumbnail
Hitoshi Ozawa, geändert vor 11 Jahren.

RE: Clean all fields button

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Your solution seems to be better than mine. Will use it the next time. :-)
thumbnail
Mazhar Alam, geändert vor 11 Jahren.

RE: Clean all fields button

Regular Member Beiträge: 191 Beitrittsdatum: 25.11.11 Neueste Beiträge
Try this,

<aui:button type="reset" value="clear"/>
thumbnail
Joseph Hobbs, geändert vor 11 Jahren.

RE: Clean all fields button

New Member Beiträge: 14 Beitrittsdatum: 10.07.12 Neueste Beiträge
What about just reloading the page? When the form is displayed it would contain whatever settings/values are present at that time. This would avoid the need to have to cache the info, and would also show any updates that another may have performed between the form display and a user clicking cancel/clean.