Fix type mapping
[MAILPOET-2453]
This commit is contained in:
committed by
Rostislav Wolný
parent
9b755dc397
commit
d8558ffec8
@@ -2,17 +2,20 @@
|
|||||||
const mapCustomField = (block, customFields, mappedCommonProperties) => {
|
const mapCustomField = (block, customFields, mappedCommonProperties) => {
|
||||||
const customField = customFields.find((cf) => cf.id === block.attributes.customFieldId);
|
const customField = customFields.find((cf) => cf.id === block.attributes.customFieldId);
|
||||||
if (!customField) return null;
|
if (!customField) return null;
|
||||||
const typesMap = {
|
|
||||||
'mailpoet-form/custom-text': 'text',
|
|
||||||
'mailpoet-form/custom-textarea': 'textarea',
|
|
||||||
'mailpoet-form/custom-radio': 'radio',
|
|
||||||
};
|
|
||||||
const mapped = {
|
const mapped = {
|
||||||
...mappedCommonProperties,
|
...mappedCommonProperties,
|
||||||
id: block.attributes.customFieldId.toString(),
|
id: block.attributes.customFieldId.toString(),
|
||||||
name: customField.name,
|
name: customField.name,
|
||||||
type: typesMap[block.name],
|
|
||||||
};
|
};
|
||||||
|
if (block.name.startsWith('mailpoet-form/custom-text')) {
|
||||||
|
mapped.type = 'text';
|
||||||
|
}
|
||||||
|
if (block.name.startsWith('mailpoet-form/custom-textarea')) {
|
||||||
|
mapped.type = 'textarea';
|
||||||
|
}
|
||||||
|
if (block.name.startsWith('mailpoet-form/custom-radio')) {
|
||||||
|
mapped.type = 'radio';
|
||||||
|
}
|
||||||
if (Object.prototype.hasOwnProperty.call(block.attributes, 'validate')) {
|
if (Object.prototype.hasOwnProperty.call(block.attributes, 'validate')) {
|
||||||
mapped.params.validate = block.attributes.validate;
|
mapped.params.validate = block.attributes.validate;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user