PDA

View Full Version : Noob: Form.isValid() returning: Uncaught TypeError: Object [object Object] has no met



keithrust
9 Dec 2011, 4:52 PM
I'm using Designer 1.2.2 and I have a Panel with a series of forms. I want to validate that the required fields are filled in by form to enable or disable different buttons. I'm having a heck of a time trying to get isValid() to work, Chrome giving the error: Uncaught TypeError: Object [object Object] has no method 'isValid'.



this.down('#ProjectPath').isValid();
return this.down('#ProjectPath').hasInvalidField();


I'm using the first line to highlight any required fields and the second line to have the function return true or false if there are any invalid fields so I know whether or not to enable the buttons. Is this an issue of not getting a handle on the form properly? I've been using this.down('#<id>') successfully so far, but I am a newbie here...

FYI, ProjectPath is the ID of the form I'm currently interested in checking for valid fields.

lorezyra
9 Dec 2011, 5:44 PM
You might want to query up to the window/panel component first before query.down to the form component. Also, you need to use the getForm() method in order to access the isValid() function.


For example...

var loginForm = me.getAdminUIlogon().down('form').getForm();
if(loginForm.isValid()){
loginForm.submit({ /* ... code block */ });
}//end if loginForm


In this example getAdminUIlogon is an automatic getter method for the window component that is nesting the form.panel. Rather than reference the form directly, I simply instruct the componentQuery to look for the form inside that window. Then get the form...

keithrust
9 Dec 2011, 5:54 PM
Sweet! getForm() was the missing ticket. I've got a lot of reading to do...