PDA

View Full Version : Checkbox/radio Bug on ext-base.js ?



shaluniska
15 May 2010, 3:19 PM
Hi All,

i have a simple { var pnl = FormPanel } with one Checkbox..{ checked:true }.

If i set the checkbox to "false" -> and call the method pnl.getForm().getValues()... i dont get the Value from the Checkbox, because the checkbox set to false !!! ??? !!

original Code:



serializeForm : function(form) {
var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
hasSubmit = false,
encoder = encodeURIComponent,
element,
options,
name,
val,
data = '',
type;

Ext.each(fElements, function(element) {
name = element.name;
type = element.type;

if (!element.disabled && name){
if(/select-(one|multiple)/i.test(type)) {
Ext.each(element.options, function(opt) {
if (opt.selected) {
data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text));
}
});
} else if(!/file|undefined|reset|button/i.test(type)) {
if(!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)){

data += encoder(name) + '=' + encoder(element.value) + '&';
hasSubmit = /submit/i.test(type);
}
}
}
});
return data.substr(0, data.length - 1);
}


my working code:




serializeForm : function(form) {
var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
hasSubmit = false,
encoder = encodeURIComponent,
element,
options,
name,
val,
data = '',
type;

Ext.each(fElements, function(element) {
name = element.name;
type = element.type;

if (!element.disabled && name){
if(/select-(one|multiple)/i.test(type)) {
Ext.each(element.options, function(opt) {
if (opt.selected) {
data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text));
}
});
} else if(!/file|undefined|reset|button/i.test(type)) {
if(!(/radio|checkbox/i.test(type))){

if(!(type == 'submit' && hasSubmit)){

data += encoder(name) + '=' + encoder(element.value) + '&';
hasSubmit = /submit/i.test(type);
}
}else
data += encoder(name) + '=' + encoder(element.value) + '&';
}
}
});
return data.substr(0, data.length - 1);
}



Help Me... It's a Bug ? :-?

Thanks you

shaluniska
15 May 2010, 4:30 PM
Hi All,

i have a simple { var pnl = FormPanel } with one Checkbox..{ checked:true }.

If i set the checkbox to "false" -> and call the method pnl.getForm().getValues()... i dont get the Value from the Checkbox, because the checkbox set to false !!! ??? !!

original Code:



serializeForm : function(form) {
var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
hasSubmit = false,
encoder = encodeURIComponent,
element,
options,
name,
val,
data = '',
type;

Ext.each(fElements, function(element) {
name = element.name;
type = element.type;

if (!element.disabled && name){
if(/select-(one|multiple)/i.test(type)) {
Ext.each(element.options, function(opt) {
if (opt.selected) {
data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text));
}
});
} else if(!/file|undefined|reset|button/i.test(type)) {
if(!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)){

data += encoder(name) + '=' + encoder(element.value) + '&';
hasSubmit = /submit/i.test(type);
}
}
}
});
return data.substr(0, data.length - 1);
}


my working code:




serializeForm : function(form) {
var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
hasSubmit = false,
encoder = encodeURIComponent,
element,
options,
name,
val,
data = '',
type;

Ext.each(fElements, function(element) {
name = element.name;
type = element.type;

if (!element.disabled && name){
if(/select-(one|multiple)/i.test(type)) {
Ext.each(element.options, function(opt) {
if (opt.selected) {
data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text));
}
});
} else if(!/file|undefined|reset|button/i.test(type)) {
if(!(/radio|checkbox/i.test(type))){

if(!(type == 'submit' && hasSubmit)){

data += encoder(name) + '=' + encoder(element.value) + '&';
hasSubmit = /submit/i.test(type);
}
}else
data += encoder(name) + '=' + encoder(element.value) + '&';
}
}
});
return data.substr(0, data.length - 1);
}



Help Me... It's a Bug ? :-?

Thanks you

Version Ext JS 3.2.1