Fix grouped custom fields not saving deselected values #333
This commit is contained in:
parent
6e3b9d209c
commit
0a369e2475
3 changed files with 13 additions and 3 deletions
|
@ -469,6 +469,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
|||
case 'radio':
|
||||
case 'checkbox':
|
||||
{
|
||||
let hasSelectedOption = (field.options || []).some(subField => subField.column && valueList[subField.column]);
|
||||
let item = {
|
||||
id: field.id,
|
||||
type: field.type,
|
||||
|
@ -481,8 +482,15 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
|||
groupTemplate: field.groupTemplate,
|
||||
options: (field.options || []).map(subField => {
|
||||
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
|
||||
// ignore missing values
|
||||
return false;
|
||||
if (hasSelectedOption && field.type !== 'checkbox') {
|
||||
// Set all radio or dropdown options if a selection for the group is present
|
||||
} else if (field.type === 'checkbox' && values['originGroupG' + field.id] === 'webform') {
|
||||
// Set all checkbox options if origin is webform (subscribe, manage, or admin edit) #333
|
||||
// Atomic updates via API call or CSV import still possible
|
||||
} else {
|
||||
// ignore missing values
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: subField.type,
|
||||
|
|
|
@ -130,6 +130,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{#if typeCheckbox}}
|
||||
<input type="hidden" name="origin_{{key}}" value="webform">
|
||||
{{#each options}}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
|
|
|
@ -130,8 +130,9 @@
|
|||
{{/if}}
|
||||
|
||||
{{#if typeCheckbox}}
|
||||
<div class="form-group checkbox">
|
||||
<div class="form-group checkbox {{key}}">
|
||||
<label>{{name}}</label>
|
||||
<input type="hidden" name="origin_{{key}}" value="webform">
|
||||
{{#each options}}
|
||||
<label class="label-checkbox">
|
||||
<input type="checkbox" name="{{column}}" value="1" {{#if value}} checked {{/if}}> {{name}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue