diff --git a/components/elements/index.js b/components/elements/index.js
index 908de2fd..f115d812 100644
--- a/components/elements/index.js
+++ b/components/elements/index.js
@@ -51,12 +51,20 @@ const RenderTextfield = ({
- {touched && error && (
-
- Error:{" "}
- {error}
-
- )}
+ {!custom.hasOwnProperty("showErrorBottom")
+ ? touched &&
+ error && (
+
+
+ Error:
+ {" "}
+ {error}
+
+ )
+ : ""}
+ {custom.hasOwnProperty("showErrorBottom")
+ ? touched &&
+ error && (
+
+
+ Error:
+ {" "}
+ {error}
+
+ )
+ : ""}
>
);
@@ -2037,7 +2059,7 @@ const renderField = ({ input, label, type, meta: { touched, error } }) => (
);
-const RenderSubFields = ({ fields }) => {
+const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => {
let { t } = useTranslation();
let subTitle = fields.name.split("pinswg_")[1];
@@ -2045,12 +2067,16 @@ const RenderSubFields = ({ fields }) => {
const checkValue = (value) => {
let errors;
- // Check for emojis using a regular expression
- const emojiRegex =
- /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2300}-\u{23FF}\u{2B50}\u{1F004}-\u{1F0CF}\u{1F0A0}-\u{1F0A5}\u{1F170}-\u{1F251}]/gu;
+ if (!value) {
+ errors = t("newappeal:is-required-label");
+ } else {
+ // Check for emojis using a regular expression
+ const emojiRegex =
+ /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2300}-\u{23FF}\u{2B50}\u{1F004}-\u{1F0CF}\u{1F0A0}-\u{1F0A5}\u{1F170}-\u{1F251}]/gu;
- if (emojiRegex.test(value)) {
- errors = "Emojis are not allowed";
+ if (emojiRegex.test(value)) {
+ errors = "Emojis are not allowed";
+ }
}
return errors;
@@ -2065,6 +2091,7 @@ const RenderSubFields = ({ fields }) => {
{subTitle == "owners" ? "Owners" : "Tenant"} #
{index + 1}
+
{
: "Tenant name"
}
className="govuk-input govuk-input--width-10"
+ showErrorBottom={true}
/>
{
dateEnd={"0"}
className="govuk-input govuk-input--width-10"
/>
+
))}
-
+
+ {fields.length < custom.maxSubField && (
+
+ )}
);
};
@@ -2123,6 +2155,7 @@ export const FieldArrayForm = (props) => {
parentFieldShowOnValue,
parentField,
maxFieldLength,
+ maxSubField,
} = props;
var showIfHasParentShowValue =
@@ -2143,7 +2176,11 @@ export const FieldArrayForm = (props) => {
<>
{" "}
{showIfHasParentShowValue && (
-
+
)}
>
);
diff --git a/components/newappeal/buildfield.js b/components/newappeal/buildfield.js
index e0e6361e..6b2e6eb8 100644
--- a/components/newappeal/buildfield.js
+++ b/components/newappeal/buildfield.js
@@ -227,6 +227,7 @@ export default function BuildField(props) {
formProps={props.props.props.props.form}
parentField={props.parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue}
+ maxSubField={props.maxSubField}
/>
);
case "{9EF39988-22BB-4f0b-BBBE-64B5A3748AEE}":
diff --git a/components/newappeal/buildrow.js b/components/newappeal/buildrow.js
index ce8e41db..fa314249 100644
--- a/components/newappeal/buildrow.js
+++ b/components/newappeal/buildrow.js
@@ -34,6 +34,7 @@ export default function BuildRow(props) {
var fieldtype = xpath.select("//@classid", doc);
var validation = xpath.select("//@validation", doc);
var maxFieldLength = xpath.select("//@maxFieldLength", doc);
+ var maxSubField = xpath.select("//@maxsubfield", doc);
var datafieldname = xpath.select("//@datafieldname", doc);
var datafieldcontent = xpath.select(
"//@datafieldcontent",
@@ -74,6 +75,9 @@ export default function BuildRow(props) {
maxFieldLength =
!_.isEmpty(maxFieldLength) && maxFieldLength[0].value;
+ maxSubField =
+ !_.isEmpty(maxSubField) && maxSubField[0].value;
+
parentField =
!_.isEmpty(parentField) && parentField[0].value;
@@ -164,6 +168,7 @@ export default function BuildRow(props) {
setFilesForAppeal={
props.props.setFilesForAppeal
}
+ maxSubField={maxSubField}
/>
);
// } else {
diff --git a/data/formsxml/planningappeals78.xml b/data/formsxml/planningappeals78.xml
index c9b3732b..afb9a268 100644
--- a/data/formsxml/planningappeals78.xml
+++ b/data/formsxml/planningappeals78.xml
@@ -148,7 +148,7 @@
-
+
@@ -160,7 +160,7 @@
-
+