1. #1
    Ext User
    Join Date
    Apr 2008
    Location
    Germany
    Posts
    71
    Vote Rating
    0
    hobbes is on a distinguished road

      0  

    Default reset form or clear all fields

    reset form or clear all fields


    Hello all,

    i am new here and try to make my very first steps after reading much documentation.
    Sorry for dumb question.

    I define a form like this:
    PHP Code:
    AddressForm = function() {    
        var 
    adrForm = new Ext.FormPanel({
            
    labelAlign'left',
            
    title'Angaben zur Adresse',
            ... 
    With a button "New Address" I create it (if not existent) and always want to clear all contents.
    PHP Code:
    if (!adrForm){
       
    adrForm = new AddressForm();
       
    adrForm.reset(); // Does not work

    If found reset() in the API. But this throws an error.
    What can I do else or am i in the wrong context for reset()?

    Thank you very much!
    Hobbes

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,145
    Vote Rating
    673
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You're declaring your own class AddressForm, then trying to call the reset method on it, so it's not going to exist.

    Code:
    var adrForm = new Ext.FormPanel({
            labelAlign: 'left',
            title: 'Angaben zur Adresse',
    }
    );
    
    //later
    adrForm.reset();

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    The problem is the reset() method is not on the FormPanel, but the BasicForm object which is bound to a form panel. So try this:

    Code:
    adrForm.getForm().reset();

  4. #4
    Ext User
    Join Date
    Apr 2008
    Location
    Germany
    Posts
    71
    Vote Rating
    0
    hobbes is on a distinguished road

      0  

    Default reset form or clear all fields

    reset form or clear all fields


    Hi evan, sfwalter,

    thank you very much!
    @evan
    Oh, thought I have it available, because it's based on Ext.FormPanel...
    So
    adrForm.getForm().reset()
    or
    adrForm.BasicForm.reset()
    can't work anyway?

    Is it a good way to declaring my own class "AddressForm" anyway if i want to use the methods of BasicForm prototype?
    Thanks again!

    Best Regards,
    Hobbes

  5. #5
    Ext User
    Join Date
    Apr 2008
    Location
    Germany
    Posts
    71
    Vote Rating
    0
    hobbes is on a distinguished road

      0  

    Default


    Quote Originally Posted by sfwalter View Post
    The problem is the reset() method is not on the FormPanel, but the BasicForm object which is bound to a form panel. So try this:
    Code:
    adrForm.getForm().reset();
    Thank you!
    works (after I redesigned my App).
    Best Regards,
    Dirk

Thread Participants: 2