PDA

View Full Version : Set fieldLabel dynamically fires only once



Clint Mercado
27 Nov 2013, 12:03 AM
i tried this:



Ext.override(Ext.form.Field, {
setFieldLabel: function(text) {
if (this.rendered) {
var labelSeparator = this.labelSeparator;
if (typeof labelSeparator == 'undefined') {
if (this.ownerCt && this.ownerCt.layout && typeof
this.ownerCt.layout.labelSeparator != 'undefined')
labelSeparator = this.ownerCt.layout.labelSeparator;
else
labelSeparator = '';
}
var formItem = this.el.up('.x-form-item', 10);
if (formItem) {
var label = formItem.child('.x-form-item-label');
if (label)
label.update(text + labelSeparator);
}
} else
this.fieldLabel = text;
}
});


but it only fires once.
I have a formpanel (form a) that lets you edit a set of data, and that set of data will be the fieldLabel of another form (form b). At start, when I "edit" the fieldLabel from form a, it works, (form b's fieldLabel is changed), but after opening form b from a button (e.i. Create button), and editting the fieldLabel (inputtin in a textfield) from form a again, the fieldLabel in form b is not changed.

the code: formItem = this.el.up('.x-form-item', 10); becomes null.
how to resolve this?

Thanks.

Clint Mercado
27 Nov 2013, 5:22 PM
Anyone?

Clint Mercado
28 Nov 2013, 4:44 PM
Ext.override(Ext.form.Field, {

setFieldLabel: function(text) {

if (this.rendered) {

var labelSeparator = this.labelSeparator;


if (typeof labelSeparator == 'undefined') {


if (this.ownerCt && this.ownerCt.layout && typeof this.ownerCt.layout.labelSeparator != 'undefined')


labelSeparator = this.ownerCt.layout.labelSeparator;


else


labelSeparator = '';


}



var formItem = this.el.up('.x-form-item', 10);



if (formItem) {


var label = formItem.child('.x-form-item-label');



if (label)


label.update(text + labelSeparator);


} else {


this.labelEl.update(text);


}


} else {


this.fieldLabel = text;


}

}

});

Gary Schlosberg
29 Nov 2013, 4:44 PM
Glad you were able to create an override, and thanks for sharing it with the community.