Commit 3ddea2a4 3ddea2a4b948a134020315bbcb130083ad9f7b71 by Nicolas Perriault

refs #259 - refactored 7c2137eb

1 parent 7c2137eb
......@@ -415,13 +415,7 @@
* @return Mixed
*/
this.getFieldValue = function getFieldValue(inputName) {
var inputs = this.findAll('[name="' + inputName + '"]'), type;
switch (inputs.length) {
case 0:
return null;
case 1:
//this.log(inputs[0].nodeName.toLowerCase(), "error");
var input = inputs[0];
function getSingleValue(input) {
try {
type = input.getAttribute('type').toLowerCase();
} catch (e) {
......@@ -433,11 +427,10 @@
// single checkbox or… radio button (weird, I know)
if (input.hasAttribute('value')) {
return input.checked ? input.getAttribute('value') : undefined;
} else {
}
return input.checked;
}
break;
default:
function getMultipleValues(inputs) {
type = inputs[0].getAttribute('type').toLowerCase();
if (type === 'radio') {
var value;
......@@ -454,7 +447,12 @@
});
return values;
}
break;
}
var inputs = this.findAll('[name="' + inputName + '"]'), type;
switch (inputs.length) {
case 0: return null;
case 1: return getSingleValue(inputs[0]);
default: return getMultipleValues(inputs);
}
};
......