3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Ext.ns('App', 'App.user');
9 * @class App.user.FormPanel
10 * A typical FormPanel extension
12 App.user.Form = Ext.extend(Ext.form.FormPanel, {
13 renderTo: 'user-form',
17 title: 'User -- All fields are required',
20 defaultType: 'textfield',
25 // private A pointer to the currently loaded record
32 initComponent : function() {
33 // build the form-fields. Always a good idea to defer form-building to a method so that this class can
34 // be over-ridden to provide different form-fields
35 this.items = this.buildForm();
38 this.buttons = this.buildUI();
40 // add a create event for convenience in our application-code.
44 * Fires when user clicks [create] button
45 * @param {FormPanel} this
46 * @param {Object} values, the Form's values object
52 App.user.Form.superclass.initComponent.call(this);
59 buildForm : function() {
61 {fieldLabel: 'Email', name: 'email', allowBlank: false, vtype: 'email'},
62 {fieldLabel: 'First', name: 'first', allowBlank: false},
63 {fieldLabel: 'Last', name: 'last', allowBlank: false}
75 handler: this.onUpdate,
79 iconCls: 'silk-user-add',
80 handler: this.onCreate,
84 handler: function(btn, ev){
85 this.getForm().reset();
95 loadRecord : function(rec) {
97 this.getForm().loadRecord(rec);
103 onUpdate : function(btn, ev) {
104 if (this.record == null) {
107 if (!this.getForm().isValid()) {
108 App.setAlert(false, "Form is invalid.");
111 this.getForm().updateRecord(this.record);
117 onCreate : function(btn, ev) {
118 if (!this.getForm().isValid()) {
119 App.setAlert(false, "Form is invalid");
122 this.fireEvent('create', this, this.getForm().getValues());
123 this.getForm().reset();
129 onReset : function(btn, ev) {
130 this.fireEvent('update', this, this.getForm().getValues());
131 this.getForm().reset();