diff --git a/src/components/EditBlock.jsx b/src/components/EditBlock.jsx
index d4942f6..f2a4a50 100644
--- a/src/components/EditBlock.jsx
+++ b/src/components/EditBlock.jsx
@@ -42,13 +42,14 @@ class EditBlock extends SubblockEdit {
if (__SERVER__) {
return
))}
{data.subblocks?.map((subblock, index) => {
- let name = getFieldName(subblock.label);
+ let name = getFieldName(subblock.label, subblock.id);
+
return (
diff --git a/src/components/View.jsx b/src/components/View.jsx
index 2c6e68b..f5d2304 100644
--- a/src/components/View.jsx
+++ b/src/components/View.jsx
@@ -49,7 +49,7 @@ const formStateReducer = (state, action) => {
const getInitialData = (data) => ({
...data.reduce(
- (acc, field) => ({ ...acc, [getFieldName(field.label)]: field }),
+ (acc, field) => ({ ...acc, [getFieldName(field.label, field.id)]: field }),
{},
),
});
@@ -92,7 +92,7 @@ const View = ({ data, id, path }) => {
const isValidForm = () => {
let v = [];
data.subblocks.forEach((subblock, index) => {
- let name = getFieldName(subblock.label);
+ let name = getFieldName(subblock.label, subblock.id);
let fieldType = subblock.field_type;
let additionalField =
config.blocks.blocksConfig.form.additionalFields?.filter(
@@ -131,7 +131,7 @@ const View = ({ data, id, path }) => {
let attachments = {};
data.subblocks.forEach((subblock, index) => {
- let name = getFieldName(subblock.label);
+ let name = getFieldName(subblock.label, subblock.id);
if (formData[name]?.value) {
formData[name].field_id = subblock.field_id;
const isAttachment = subblock.field_type === 'attachment';
diff --git a/src/components/utils.js b/src/components/utils.js
index 7941035..9398fa7 100644
--- a/src/components/utils.js
+++ b/src/components/utils.js
@@ -1,7 +1,9 @@
import { saveAs } from 'file-saver';
-export const getFieldName = (label) => {
- return label?.toLowerCase().replace(/[^a-zA-Z0-9]/g, '_');
+export const getFieldName = (label, id) => {
+ return label?.length > 0
+ ? label?.toLowerCase().replace(/[^a-zA-Z0-9]/g, '_')
+ : id;
};
/**