Skip to content

Commit

Permalink
Fixed getFormValues
Browse files Browse the repository at this point in the history
getFormValues function now properly leaves out unchecked checkboxes
from the data array. This gives widget update functions a value that
they’re more likely to expect.
  • Loading branch information
gregpriday committed Dec 12, 2014
1 parent 796f3a3 commit 4606935
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions js/siteorigin-panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
if( hasChanged ) {
// We'll trigger our own change events
this.trigger('change');
this.trigger('change:values')
this.trigger('change:values');
}
},

Expand Down Expand Up @@ -2074,7 +2074,7 @@
fieldValue = $$.val() != '' ? $$.val() : true;
}
else {
fieldValue = false;
fieldValue = null;
}
}
else if( $$.attr('type') == 'radio' ){
Expand All @@ -2098,7 +2098,7 @@
else if ( $$.prop('tagName') == 'SELECT' ) {
fieldValue = $$.find('option:selected').val();
}
if( fieldValue == null ) {
else {
fieldValue = $$.val();
}

Expand All @@ -2118,15 +2118,17 @@
}

// Now convert this into an array
for(var i = 0; i < parts.length; i++) {
if(i == parts.length - 1) {
sub[parts[i]] = fieldValue;
}
else {
if(typeof sub[parts[i]] == 'undefined') {
sub[parts[i]] = {};
if(fieldValue !== null) {
for (var i = 0; i < parts.length; i++) {
if (i == parts.length - 1) {
sub[parts[i]] = fieldValue;
}
else {
if (typeof sub[parts[i]] == 'undefined') {
sub[parts[i]] = {};
}
sub = sub[parts[i]];
}
sub = sub[parts[i]];
}
}

Expand Down
Loading

0 comments on commit 4606935

Please sign in to comment.