PDA

View Full Version : [FIXED] [4.0.2] formBind no longer functions



DDarko
10 Jun 2011, 2:17 AM
in 4.0.1 formBind functioned perfectly in 4.0.2 stopped working.

DDarko
10 Jun 2011, 5:17 AM
"labelAlign" also appears to not work in the latest version. gray theme.

ldonofrio
10 Jun 2011, 8:14 AM
+1 seems that formBind doesn't work if the form is rendered to the dom (renderTo).

Test case:


var form = Ext.widget('form', {
defaultType: 'textfield',
renderTo: document.body,
border: false,
fieldDefaults: {
labelWidth: 70,
labelAlign: 'top',
//msgTarget: 'none',
//preventMark: true,
enableKeyEvents: true
},
items: [{
itemId: 'userName',
fieldLabel: 'Usuario',
name: 'userName',
width: 185,
allowBlank: false,
listeners: {
keypress: function(txt, e){
if(e.getCharCode() == 13) {
//doLogin();
}
}
}
},{
itemId: 'password',
fieldLabel: 'Contraseņa',
name: 'password',
width: 185,
allowBlank: false,
inputType: 'password',
listeners: {
keypress: function(txt, e){
if(e.getCharCode() == 13) {
//doLogin();
}
}
}
}],
buttons: [{
itemId: 'signin',
text: 'Ingresar',
//disabled: true,
//handler: doLogin,
formBind: true
}]
});

dbradicich
13 Jun 2011, 5:30 PM
I have found the following override to resolve this



// add a workaround for bug where boundItems aren't properly
// recalculated when necessary
// if there are 0 bound items, we will always recheck
Ext.form.Basic.override({
getBoundItems : function() {
var boundItems = this._boundItems;
if (!boundItems || boundItems.getCount() == 0) {
boundItems = this._boundItems = Ext.create('Ext.util.MixedCollection');
boundItems.addAll(this.owner.query('[formBind]'));
}
return boundItems;
}
});

westy
16 Jun 2011, 12:46 AM
Thanks for the override :)

ldonofrio
17 Jun 2011, 6:51 AM
Sweet thanks, i was thinking about publishing my overrides.js file, it's really a framework!!


I have found the following override to resolve this



// add a workaround for bug where boundItems aren't properly
// recalculated when necessary
// if there are 0 bound items, we will always recheck
Ext.form.Basic.override({
getBoundItems : function() {
var boundItems = this._boundItems;
if (!boundItems || boundItems.getCount() == 0) {
boundItems = this._boundItems = Ext.create('Ext.util.MixedCollection');
boundItems.addAll(this.owner.query('[formBind]'));
}
return boundItems;
}
});

DDarko
17 Jun 2011, 6:54 AM
A little bit helps, but it is not fully solve the problem.

ldonofrio
28 Jun 2011, 7:49 AM
I was having problems showing a window form, the formBind button is not disabled initially.

This is my override (using the dbradicich override too). Basically i'm forcing the form validity check before the FormPanel renders.



Ext.override(Ext.form.Basic, {
getBoundItems: function() {
var boundItems = this._boundItems;
if (!boundItems || boundItems.getCount() == 0) {
boundItems = this._boundItems = Ext.create('Ext.util.MixedCollection');
boundItems.addAll(this.owner.query('[formBind]'));
}
return boundItems;
},
initialize: function(){
this.callOverridden();
this.owner.on('beforerender', this.checkValidity, this);
}
});

andyjl
30 Jun 2011, 8:55 AM
+1 formBind isn't working for me either.

Thanks for the override. That made it work.

stevil
30 Jun 2011, 9:25 AM
@ldonofrio - maybe we should open up a couple of overrides threads - one for suggestions/discussion, one for posting override code (and smack down anyone who posts discussion there)?

stevil

ldonofrio
30 Jun 2011, 10:34 AM
I agree, anyway this is an ignored bug (maybe because of the thread title?)........

@ldonofrio - maybe we should open up a couple of overrides threads - one for suggestions/discussion, one for posting override code (and smack down anyone who posts discussion there)?

stevil

stevil
30 Jun 2011, 11:26 AM
I agree, anyway this is an ignored bug (maybe because of the thread title?)........

Perhaps the OP's implication was that 4.0.2 WAS the bug ;)

stevil

westy
3 Aug 2011, 8:07 AM
This still not fixed in 4.0.5, keeping my override...

westy
31 Aug 2011, 7:06 AM
And still there in 4.0.6...

edspencer
31 Aug 2011, 6:17 PM
@westy you're saying the case where you render a form using renderTo breaks binding unless you use the following override?:




// add a workaround for bug where boundItems aren't properly
// recalculated when necessary
// if there are 0 bound items, we will always recheck
Ext.form.Basic.override({
getBoundItems : function() {
var boundItems = this._boundItems;
if (!boundItems || boundItems.getCount() == 0) {
boundItems = this._boundItems = Ext.create('Ext.util.MixedCollection');
boundItems.addAll(this.owner.query('[formBind]'));
}
return boundItems;
}
});

If so it should be trivial to address this in 4.0.7

westy
1 Sep 2011, 1:28 AM
Yes.

Not sure what the reason is for the bound items to not be refreshed correctly (that might be the proper fix), but this workaround does work, and seems to be widely used.

Cheers,
Westy

ldonofrio
1 Sep 2011, 5:11 AM
Ed, please note that there is a problem with form inside a window too, the form is not validated on render, i know that is trivial and i'm reporting this since 4.0.2.

My override including dbradicich's one is: (Note the listener attached in initilize method)


Ext.override(Ext.form.Basic, {
getBoundItems: function() {
var boundItems = this._boundItems;
if (!boundItems || boundItems.getCount() == 0) {
boundItems = this._boundItems = Ext.create('Ext.util.MixedCollection');
boundItems.addAll(this.owner.query('[formBind]'));
}
return boundItems;
},
initialize: function(){
this.callOverridden();
this.owner.on('beforerender', this.checkValidity, this);
}
});


Thanks

Leonardo

edspencer
1 Sep 2011, 12:53 PM
Ok this is now fixed in 4.0.7. Sending Jason to this thread to look at the separate validity checking on load issue

westy
2 Sep 2011, 1:34 AM
Thanks Ed, good to see you're picking up these review comment style bugs! :)

ldonofrio
2 Sep 2011, 4:40 AM
+1 Thanks Ed

Thanks Ed, good to see you're picking up these review comment style bugs! :)

bee
14 Sep 2011, 2:52 PM
Hi guys, I am using ext4.0.2a. I am not able to check condition of empty field on submit. So I tried to use override, but no use can anybody suggest me how to and to use override functionality