Forum

Accueil » Alloy UI » English

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Maximiliano Chiesa
Clean all fields button
20 juillet 2012 10:43
Réponse

Maximiliano Chiesa

Rang: Junior Member

Publications: 47

Date d'inscription: 20 juillet 2012

Publications Récentes

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!
Hitoshi Ozawa
RE: Clean all fields button
20 juillet 2012 20:41
Réponse

Hitoshi Ozawa

Rang: Liferay Legend

Publications: 7952

Date d'inscription: 23 mars 2010

Publications Récentes

Create a javascript to initialize settings and have button call this method onClick().

<aui:button onClick="<%= initForm() %>" type="cancel" value="Clean" />
Joseph Hobbs
RE: Clean all fields button
24 juillet 2012 06:23
Réponse

Joseph Hobbs

Rang: New Member

Publications: 14

Date d'inscription: 10 juillet 2012

Publications Récentes

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.
Maximiliano Chiesa
RE: Clean all fields button
24 juillet 2012 06:40
Réponse

Maximiliano Chiesa

Rang: Junior Member

Publications: 47

Date d'inscription: 20 juillet 2012

Publications Récentes

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!
Hitoshi Ozawa
RE: Clean all fields button
24 juillet 2012 14:29
Réponse

Hitoshi Ozawa

Rang: Liferay Legend

Publications: 7952

Date d'inscription: 23 mars 2010

Publications Récentes

Your solution seems to be better than mine. Will use it the next time. :-)
Mazhar Alam
RE: Clean all fields button
13 janvier 2013 22:41
Réponse

Mazhar Alam

Rang: Regular Member

Publications: 188

Date d'inscription: 25 novembre 2011

Publications Récentes

Try this,

<aui:button type="reset" value="clear"/>