PDA

View Full Version : [DUPE-477][3.1] allowBlank doesn't work to combobox when defaults is set.



leandrorc
24 Jan 2010, 3:15 PM
Hi people,

I have a combobox and when "defaults:{allowBlank:false}" is set, setting "allowBlank:true" in combobox doesn't work, so it doesn't allow blank anyway.

Ps: tested in Firefox 3.5 and IE 8, with ExtJs 3.1

Try it by yourself here:
http://www.startweb.com.br/test.php

Condor
24 Jan 2010, 10:52 PM
Unfortunately, this is by design.

'defaults' are only applied to config objects if the options aren't already specified, but they are always applied to component instances.

I've posted a feature request (http://www.extjs.com/forum/showthread.php?t=65457) to change this quirky behavior.

leandrorc
25 Jan 2010, 2:32 PM
This is really bad! Defaults should be always defaults! :D

leandrorc
25 Jan 2010, 3:03 PM
I found another problem:

I set defaults:{defaultType:'textfield', allowBlank:false} in the formpanel. Then, i add a fieldset inside it, with two fields and moved the combobox to inside this fieldset. The two fields was correctly rendered as textfields, but they allow blank, and it's not correct (remember allowBlank:false in defaults), and now, combobox respects its "allowBlank:true" config.

So, i think default should be recursively applied, ain't?

Take a look:
http://www.startweb.com.br/test2.php

Condor
25 Jan 2010, 11:38 PM
No, defaults are not applied to children of children. But I don't think that should be changed.

leandrorc
27 Jan 2010, 2:15 PM
But it would be good to save lines of code! ;)

Jamie Avins
27 Jan 2010, 2:33 PM
Or add a whole lot having to clear unwanted defaults down the tree.

leandrorc
28 Jan 2010, 3:51 PM
Hum, recursive defaults could cause a big performance issue, is it?

Condor
28 Jan 2010, 11:59 PM
Hum, recursive defaults could cause a big performance issue, is it?

No, it's not a question of performance. It's a question of maintainability. It would be hard to oversee the results of defaults in a deeply nested layout.

Did you know that you can nest defaults, e.g.

{
xtype: 'container',
layout: 'column',
defaults: {
columnWidth: 0.5,
xtype: 'container',
layout: 'form',
defaults: {
anchor: '0',
xtype: 'textfield',
allowBlank: false
}
},
items: [{
items: {
fieldLabel: 'Left',
name: 'left'
}
},{
items: {
fieldLabel: 'Right',
name: 'right'
}
}]
}