PDA

View Full Version : clearInvalid() Fields using BasicForm how use it?



HCammus
22 Nov 2007, 2:00 PM
Hi all, first sorry if this question yet solved, but I can't found and take some hours try to solved this "problem" and try to found a solution here too.

I take a js code with this:



var formEqu = new Ext.form.BasicForm('formEqu', {
id: 'formEqu',
trackResetOnLoad: true,
method: 'POST'
});

formEqu.render();

var idEqu = new Ext.form.TextField({
allowBlank: false,
applyTo: 'idEqu'
});

...


How return the fields to normal state?

I try with clearInvalid() using Ext.get(formElement); but doesn't work for me, I need a standard function as this:


function resetForm(formName) {
code for any id form to reset and put the fields in the normal mode.
}

coz I use some forms in the same window.

Any help?

tryanDLS
22 Nov 2007, 2:31 PM
clearInvalid is a fn of a BasicForm, not Element. Ext.get != Ext.getCmp. Read the doc for these 2 functions and understand what is being returned.

HCammus
22 Nov 2007, 3:07 PM
Yeah I read the doc, but don't mention this, but now remember something about the "fn", and the Ext.getCmp don't get the property either, I try some examples of here but I can't get the instance of the object and the clearInvalid() "function".

I try to search again and read more about this function, thx for the answer.

tryanDLS
22 Nov 2007, 3:42 PM
Did you actually try?

Ext.getCmp('formEqu').clearInvalid()

HCammus
23 Nov 2007, 7:11 AM
Hi yeah I try this, but using this:



function resetForm(formName) {
var form = Ext.getCmp(formName);

form.clearInvalid();
}


FireBug show me this:

Ext.getCmp(formName) has no properties
Ext.getCmp(formName).clearInvalid();

tryanDLS
23 Nov 2007, 7:53 AM
What is the value of 'formName' when you make that call? You have to do some debugging and provide information for people to work with.

HCammus
23 Nov 2007, 8:28 AM
Hi again, sorry I forgot mentioned this:

The value is the ID of any form that I take in the html code, for example I have something like this:

[HTML]
<div id="fac-win" class="x-hidden">
<div class="x-window-header">Facultades</div>
<div id="fac-tabs">
<div class="x-tab" title="Nueva Facultad">
<form id="formFac" name="formFac" onSubmit="return false;" class="x-form">
<div class="x-form-item" style="position:relative;left:12px;top:10px;">
<label for="idFac">C

tryanDLS
23 Nov 2007, 9:27 AM
Please go back and read my original response and understand what's going on. You can not pass the name of a FORM tag - clearInvalid is a method of the BasicForm object, not the dom element. You can not call Ext.getCmp() with the id of a dom element - it must be a BasicForm instance.

HCammus
23 Nov 2007, 10:31 AM
Please go back and read my original response and understand what's going on. You can not pass the name of a FORM tag - clearInvalid is a method of the BasicForm object, not the dom element. You can not call Ext.getCmp() with the id of a dom element - it must be a BasicForm instance.

Ahhh now understand, thanks, but how solved the problem then?