Browse Source

Fix radio/checkbox output from serialize caused by formatting changes #1630

pull/1698/merge
jlukic 9 years ago
parent
commit
3de207e0ad
1 changed files with 18 additions and 4 deletions
  1. 22
      src/definitions/behaviors/form.js

22
src/definitions/behaviors/form.js

@ -178,16 +178,30 @@ $.fn.form = function(fields, parameters) {
$field = $(this),
type = $field.prop('type'),
name = $field.prop('name'),
value = $field.val(),
isCheckbox = $field.is(selector.checkbox),
isRadio = $field.is(selector.radio),
isChecked = (isCheckbox)
? $field.is(':checked')
: false
;
if(isCheckbox && !isChecked) {
module.debug('Omitted unchecked checkbox', $field);
return true;
if(isRadio) {
if(isChecked) {
data[name] = value;
}
}
else if(isCheckbox) {
if(isChecked) {
data[name] = true;
}
else {
module.debug('Omitted unchecked checkbox', $field);
return true;
}
}
else {
data[name] = value;
}
data[name] = $field.val();
})
;
return data;

Loading…
Cancel
Save