title: Getting form from click event in Controller in ExtJS?
body: <p>I am extending the example given in <a href="http://docs.sencha.com/architect/2-0/#!/guide/views_forms_extjs" rel="nofollow">http://docs.sencha.com/architect/2-0/#!/guide/views_forms_extjs</a> to use a more MVC centric approach. So in service of that I want to move the on click handler from the view to a newly create controller.</p>
  
  <p>I have the click even working fine, but I have no idea how to operate on the form from the context of the controller (the view was using this.getForm()).</p>
  
  <p>Here is what I have so far,</p>
  
  <pre><code>Ext.define('LoginExample.controller.LoginController', {
      extend: 'Ext.app.Controller',
  
  
      onLoginButtonClick: function(button, e, options) {
          console.log('button clicked');
  
  
          if (this.getForm().isValid()) {
              this.getForm().submit({
                  url: 'login.php',
                  success: function(form, action) {
                      Ext.Msg.alert('Login Successful!');
                  },
                  failure: function(form, action) {
                      Ext.Msg.alert('Login Failed!');
                  }
              });
          }
      },
  
  
      init: function() {
          this.control({
              "#loginButton": {
                  click: this.onLoginButtonClick
              }
          });
      }
  
  });
  </code></pre>
  
  <p>Obviously the this in the context of onLoginButtonClick is no longer the view and is instead the controller.</p>
  
  <p>Given the parameters given to me, (Ext.button.Button button, Event e, Object options), how do I get the submit on the appropriate form?</p>
  
  <p>I should note this using ExtJS 4.</p>