Ext.override(Ext.form.Checkbox, { onRender : function(ct, position){ Ext.form.Checkbox.superclass.onRender.call(this, ct, position); if(this.inputValue !== undefined){ this.el.dom.value = this.inputValue; } this.wrap = this.el.wrap({cls: 'x-form-check-wrap'}); if(this.boxLabel){ this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel}); } if(this.checked){ this.setValue(true); }else{ this.checked = this.el.dom.checked; } if (Ext.isIE && !Ext.isStrict) { this.wrap.repaint(); } this.resizeEl = this.positionEl = this.wrap; } }); Ext.namespace('strictlyPHP'); strictlyPHP.FormWindow = Ext.extend(Ext.Window, { resizable: false, modal: true, layout: 'form', submitOnEnter: false, _bindSubmitTo: ['textfield', 'textarea'], _formPanel: null, _submitCallBack: null, initComponent: function() { strictlyPHP.FormWindow.superclass.initComponent.call(this); }, show: function(options) { strictlyPHP.FormWindow.superclass.show.call(this, options); //adds keymap for Enter to compontent to simulate the default button click after render if (this.submitOnEnter) { var windowId = this.id; var keymap = new Ext.KeyMap(windowId, { key: Ext.EventObject.ENTER, scope: this, fn: function() { if (this._submitCallBack === null) { this._submitCallBack = this.defaultButton.handler; } this.defaultButton.setHandler(Ext.emptyFn); this._submitCallBack(); } }); } }, setFormPanel: function(panel) { this._formPanel = panel; this.add(panel); }, getFormPanel: function() { return this._formPanel; } }); strictlyPHP.StaticTextField = Ext.extend(Ext.form.TextField, { fieldClass: 'x-static-text-field', onRender: function() { Ext.apply(this, { readOnly: true, disabled: !this.initialConfig.submitValue }); strictlyPHP.StaticTextField.superclass.onRender.apply(this, arguments); } }); Ext.reg('statictextfield', strictlyPHP.StaticTextField); strictlyPHP.AddressField = Ext.extend(Ext.Panel, { layout: 'form', border: false, allowBlank: ['box', 'postalCode'], emptyTexts: { street: 'Straat', number: 'Nr', box: '(Bus)', postalCode: '(Postcode)', city: 'Plaats', country: 'Land' }, defaults: {hideLabel: true}, deferredRender: false, initComponent: function() { Ext.apply(this, { items: [{ xtype: 'compositefield', defaults: {xtype: 'textfield'}, items: [ {name: 'street', flex: 1, allowBlank: this.allowBlank.indexOf('street') >= 0, emptyText: this.emptyTexts.street}, {name: 'number', width: 38, allowBlank: this.allowBlank.indexOf('number') >= 0, emptyText: this.emptyTexts.number}, {name: 'box', width: 38, allowBlank: this.allowBlank.indexOf('box') >= 0, emptyText: this.emptyTexts.box} ] }, { xtype: 'compositefield', defaults: {xtype: 'textfield'}, items: [ {name: 'postalCode', width: 100, allowBlank: this.allowBlank.indexOf('postalCode') >= 0, emptyText: this.emptyTexts.postalCode}, {name: 'city', flex: 1, allowBlank: this.allowBlank.indexOf('city') >= 0, emptyText: this.emptyTexts.city} ] }, { xtype: 'combo', name: 'country', hiddenName: 'country', emptyText: this.emptyTexts.country, triggerAction: 'all', forceSelection: true, editable: false, allowBlank: this.allowBlank.indexOf('country') >= 0, lazyInit: false, store: new Ext.data.JsonStore({ autoLoad: true, url: Cms.ajaxUrl + '/get-countries', root: 'data', fields: ['code', 'name'] }), displayField: 'name', valueField: 'code' }] }); strictlyPHP.AddressField.superclass.initComponent.call(this); } }); Ext.reg('address', strictlyPHP.AddressField); strictlyPHP.TypeField = Ext.extend(Ext.form.ComboBox, { xtype: 'combo', width: 200, triggerAction: 'all', loadingText: 'Bezig met laden...', displayField: 'name', valueField: 'code', lazyInit: false, forceSelection: true, mode: 'local', valueNotFoundText: 'Selecteer een type', editable: false, initialValue: null, initComponent: function() { Ext.apply(this, { hiddenName: this.name, store: new Ext.data.JsonStore({ url: this.url, root: 'data', fields: ['code', 'name'], autoLoad: true }) }); strictlyPHP.TypeField.superclass.initComponent.call(this); }, onSelect: function() { strictlyPHP.TypeField.superclass.onSelect.apply(this, arguments); // Type change confirmation (current content will be deleted) if (!Ext.isEmpty(this.getValue()) && !Ext.isEmpty(this.initialValue) && this.getValue() != this.initialValue) { Ext.MessageBox.confirm(this.changeTitle, this.changeInfo, function(btn, text) { if (btn == 'yes') { this.initialValue = this.getValue(); if (!Ext.isEmpty(this.changeCallback)) { this.changeCallback(); } } else { this.setValue(this.initialValue); } }, this); } else { if (!Ext.isEmpty(this.changeCallback)) { this.changeCallback(); } } }, clearValue: function() { strictlyPHP.TypeField.superclass.clearValue.call(this); this.initialValue = null; if (!Ext.isEmpty(this.changeCallback)) { this.changeCallback(); } }, setValue: function(value) { strictlyPHP.TypeField.superclass.setValue.call(this, value); // if (Ext.isEmpty(this.initialValue) && !Ext.isEmpty(value)) { // this.initialValue = value; // } } }); Ext.reg('typefield', strictlyPHP.TypeField);