PDA

View Full Version : validator doesn't work



GridGridGrid
11 Jan 2013, 1:21 AM
I've added a validator to a combobox and since then my complete Shopware-SupApplication doesn't show up any more. I can't see what I've done wrong?

Form has "clientValidation: true"



{
xtype: 'combo',
store: statusStore,
queryMode: 'local',
valueField:'value',
value:'status',
name:'status',
displayField:'description',
anchor : '95%',
fieldLabel : '{s name=status}Status{/s}',
validator: function(value) {
if (value == '2') {return true;}
return false;
}
}


Opera-Console:



POST http://dev.make-my-tape.de/backend/Baehr/load/?no-cache=1357894046+1+1 503 (Service Unavailable) ext-all.js:21
Ext.define.request ext-all.js:21
(anonymous function) base:294
Ext.Object.each ext-all.js:21
Ext.apply.iterate ext-all.js:21
Ext.Loader.require base:272
(anonymous function) ext-all.js:21
hooks.onBeforeCreated base:1587
Ext.apply.doProcess ext-all.js:21
Ext.apply.doProcess ext-all.js:21
(anonymous function) ext-all.js:21
Ext.Loader.require base:233
(anonymous function) ext-all.js:21
Ext.apply.doProcess ext-all.js:21
Ext.apply.doProcess ext-all.js:21
Ext.apply.process ext-all.js:21
Ext.Class.c ext-all.js:21
Ext.ClassManager.create ext-all.js:21
Ext.apply.define ext-all.js:21
(anonymous function) /backend/Baehr?file=app&no-cache=1357894046+1+1:1
(anonymous function) ext-all.js:21
Ext.globalEval ext-all.js:21
Ext.apply.loadScriptFile ext-all.js:21
Ext.Loader.require base:262
Ext.apply.syncRequire ext-all.js:21
(anonymous function) ext-all.js:21
Ext.ClassManager.instantiate ext-all.js:21
(anonymous function) ext-all.js:21
Ext.override.addController base:39
Ext.override.addSubApplication base:61
menu.Ext.create.items.handler
Ext.apply.callback ext-all.js:21
Ext.define.onClick ext-all.js:21
Ext.define.onClick ext-all.js:21
(anonymous function)
g ext-all.js:21



Uncaught TypeError: object is not a function
(anonymous function)
Ext.ClassManager.instantiate ext-all.js:21
(anonymous function) ext-all.js:21
Ext.override.addController base:39
Ext.override.addSubApplication base:61
menu.Ext.create.items.handler
Ext.apply.callback ext-all.js:21
Ext.define.onClick ext-all.js:21
Ext.define.onClick ext-all.js:21
(anonymous function)
g

mitchellsimoens
13 Jan 2013, 9:07 AM
A simple example is working for me:


var states = Ext.create('Ext.data.Store', {
fields : ['abbr', 'name'],
data : [
{ abbr : 'One', name : '1' },
{ abbr : 'Two', name : '2' },
{ abbr : 'Three', name : '3' }
]
});

Ext.create('Ext.form.ComboBox', {
fieldLabel : 'Choose Value',
store : states,
queryMode : 'local',
displayField : 'name',
valueField : 'abbr',
renderTo : Ext.getBody(),
validator : function(val) {
return val === '2'; //simplified return than what you had
}
});

GridGridGrid
14 Jan 2013, 9:50 AM
Thanks. It works now. I expected the 'valueField' to be the one that will be passed to the validator...?