diff --git a/assets/js/src/form_editor/blocks/custom_textarea/custom_field_settings.jsx b/assets/js/src/form_editor/blocks/custom_textarea/custom_field_settings.jsx
new file mode 100644
index 0000000000..a522ac78d7
--- /dev/null
+++ b/assets/js/src/form_editor/blocks/custom_textarea/custom_field_settings.jsx
@@ -0,0 +1,127 @@
+import React, { useState } from 'react';
+import {
+ Button,
+ SelectControl,
+ ToggleControl,
+} from '@wordpress/components';
+import PropTypes from 'prop-types';
+import MailPoet from 'mailpoet';
+import { useDispatch, useSelect } from '@wordpress/data';
+
+const CustomFieldSettings = ({
+ mandatory,
+ validate,
+ lines,
+ customFieldId,
+ updateAttributes,
+}) => {
+ const [localMandatory, setLocalMandatory] = useState(mandatory);
+ const [localValidate, setLocalValidate] = useState(validate);
+ const [localLines, setLocalLines] = useState(lines);
+ const { saveCustomField } = useDispatch('mailpoet-form-editor');
+ const isSaving = useSelect(
+ (sel) => sel('mailpoet-form-editor').getIsCustomFieldSaving(),
+ []
+ );
+
+ return (
+ <>
+
+
+
+
+
+ >
+ );
+};
+
+CustomFieldSettings.propTypes = {
+ mandatory: PropTypes.bool,
+ validate: PropTypes.string,
+ lines: PropTypes.string,
+ customFieldId: PropTypes.number.isRequired,
+ updateAttributes: PropTypes.func.isRequired,
+};
+
+CustomFieldSettings.defaultProps = {
+ mandatory: false,
+ validate: '',
+ lines: '1',
+};
+
+export default CustomFieldSettings;
diff --git a/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx b/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx
index 05805ab154..8d2ee0697e 100644
--- a/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx
+++ b/assets/js/src/form_editor/blocks/custom_textarea/edit.jsx
@@ -2,7 +2,6 @@ import React from 'react';
import {
Panel,
PanelBody,
- SelectControl,
TextControl,
ToggleControl,
} from '@wordpress/components';
@@ -10,9 +9,21 @@ import { InspectorControls } from '@wordpress/block-editor';
import PropTypes from 'prop-types';
import MailPoet from 'mailpoet';
+import CustomFieldSettings from './custom_field_settings.jsx';
+
const CustomTextAreaEdit = ({ attributes, setAttributes }) => {
const inspectorControls = (
+
+
+ (setAttributes(attrs))}
+ customFieldId={attributes.customFieldId}
+ mandatory={attributes.mandatory}
+ validate={attributes.validate}
+ />
+
+
{
checked={attributes.labelWithinInput}
onChange={(labelWithinInput) => (setAttributes({ labelWithinInput }))}
/>
- (setAttributes({ mandatory }))}
- />
- (setAttributes({ validate }))}
- />
- (setAttributes({ lines }))}
- />
@@ -93,7 +50,7 @@ const CustomTextAreaEdit = ({ attributes, setAttributes }) => {
name="custom_text"
disabled
data-automation-id="editor_custom_text_input"
- defaultValue={placeholder}
+ value={placeholder}
rows={attributes.lines}
/>
);