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 'radio':
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
{
|
{
|
||||||
|
let hasSelectedOption = (field.options || []).some(subField => subField.column && valueList[subField.column]);
|
||||||
let item = {
|
let item = {
|
||||||
id: field.id,
|
id: field.id,
|
||||||
type: field.type,
|
type: field.type,
|
||||||
|
@ -481,8 +482,15 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
groupTemplate: field.groupTemplate,
|
groupTemplate: field.groupTemplate,
|
||||||
options: (field.options || []).map(subField => {
|
options: (field.options || []).map(subField => {
|
||||||
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
|
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
|
||||||
// ignore missing values
|
if (hasSelectedOption && field.type !== 'checkbox') {
|
||||||
return false;
|
// 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 {
|
return {
|
||||||
type: subField.type,
|
type: subField.type,
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if typeCheckbox}}
|
{{#if typeCheckbox}}
|
||||||
|
<input type="hidden" name="origin_{{key}}" value="webform">
|
||||||
{{#each options}}
|
{{#each options}}
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
|
|
|
@ -130,8 +130,9 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if typeCheckbox}}
|
{{#if typeCheckbox}}
|
||||||
<div class="form-group checkbox">
|
<div class="form-group checkbox {{key}}">
|
||||||
<label>{{name}}</label>
|
<label>{{name}}</label>
|
||||||
|
<input type="hidden" name="origin_{{key}}" value="webform">
|
||||||
{{#each options}}
|
{{#each options}}
|
||||||
<label class="label-checkbox">
|
<label class="label-checkbox">
|
||||||
<input type="checkbox" name="{{column}}" value="1" {{#if value}} checked {{/if}}> {{name}}
|
<input type="checkbox" name="{{column}}" value="1" {{#if value}} checked {{/if}}> {{name}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue