getAFValue() function in jquery.yiiactiveform.js is causing a trouble in one of my projects …
I’m not sure if it’s a bug or my mistake, but please take a look at it.
var getAFValue = function (o) {
var type = o.attr('type');
if (o[0].tagName.toLowerCase()=='span'){
var c = [];
o.find(':checked').each(function () {
c.push(this.value);
});
return c.join(',');
}
if (type === 'checkbox' || type === 'radio') {
return o.filter(':checked').val();
} else {
return o.val();
}
};
In most of the case it works fine. But the parameter o[0]
sometimes becomes undefined
and the function will break. The function was called from the line 59 of the script.
Here is my work around.
var getAFValue = function (o) {
var type = o.attr('type');
if (typeof o[0] !== 'undefined' && o[0].tagName.toLowerCase()=='span'){
var c = [];
o.find(':checked').each(function () {
c.push(this.value);
});
return c.join(',');
}
if (type === 'checkbox' || type === 'radio') {
return o.filter(':checked').val();
} else {
return o.val();
}
};
FYI, I’m using JuiTabs and JuiDatepicker in the problematic page, though I don’t know whether it’s relevant or not.
[EDIT]
Probably the same issue …
http://code.google.com/p/yii/issues/detail?id=3070
[EDIT 2]
OK, I’ve got it. It was just the same for me.
find() function in the line 59 was returning an input field rendered INSIDE a HTML comment, and getAFValue() was called with an unexpected value.
So I’ve deleted the HTML commented lines altogether, and the problem was solved.
But I’m afraid there should be many guys who will have the same problem when they upgraded yii to 1.1.9.