[BUGFIX] Form editor breaks if property path does not exist 16/56716/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Sat, 17 Mar 2018 16:41:47 +0000 (17:41 +0100)
committerBenjamin Kott <benjamin.kott@outlook.com>
Tue, 17 Apr 2018 22:07:15 +0000 (00:07 +0200)
If a property path - which should be validated within the form editor -
does not exist within the form definition and this property is not
defined through the 'predefinedDefaults' within the setup, the
form editor must not break.

Resolves: #84448
Releases: master, 8.7
Change-Id: I3c5d4ebb1afb43f5a9bbc5839c8116d0d16e8f4b
Reviewed-on: https://review.typo3.org/56326
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Kay Strobach <typo3@kay-strobach.de>
Tested-by: Kay Strobach <typo3@kay-strobach.de>
Reviewed-by: Björn Jacob <bjoern.jacob@tritum.de>
Tested-by: Björn Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Benjamin Kott <benjamin.kott@outlook.com>
Tested-by: Benjamin Kott <benjamin.kott@outlook.com>
Reviewed-on: https://review.typo3.org/56716

typo3/sysext/form/Resources/Public/JavaScript/Backend/FormEditor/ViewModel.js

index 6e8cf91..7acc56f 100644 (file)
@@ -213,12 +213,18 @@ define(['jquery',
       });
 
       getFormEditorApp().addPropertyValidationValidator('NaiveEmail', function(formElement, propertyPath) {
+        if (getUtility().isUndefinedOrNull(formElement.get(propertyPath))) {
+          return;
+        }
         if (!formElement.get(propertyPath).match(/\S+@\S+\.\S+/)) {
           return getFormEditorApp().getFormElementPropertyValidatorDefinition('NaiveEmail')['errorMessage'] || 'invalid value';
         }
       });
 
       getFormEditorApp().addPropertyValidationValidator('NaiveEmailOrEmpty', function(formElement, propertyPath) {
+        if (getUtility().isUndefinedOrNull(formElement.get(propertyPath))) {
+          return;
+        }
         if (formElement.get(propertyPath).length > 0 && !formElement.get(propertyPath).match(/\S+@\S+\.\S+/)) {
           return getFormEditorApp().getFormElementPropertyValidatorDefinition('NaiveEmailOrEmpty')['errorMessage'] || 'invalid value';
         }
@@ -226,6 +232,11 @@ define(['jquery',
 
       getFormEditorApp().addPropertyValidationValidator('FormElementIdentifierWithinCurlyBracesInclusive', function(formElement, propertyPath) {
         var match, regex;
+
+        if (getUtility().isUndefinedOrNull(formElement.get(propertyPath))) {
+          return;
+        }
+
         regex = /\{([a-z0-9-_]+)?\}/gi;
         match = regex.exec(formElement.get(propertyPath));
         if (match && ((match[1] && !getFormEditorApp().isFormElementIdentifierUsed(match[1])) || !match[1])) {
@@ -235,6 +246,11 @@ define(['jquery',
 
       getFormEditorApp().addPropertyValidationValidator('FormElementIdentifierWithinCurlyBracesExclusive', function(formElement, propertyPath) {
         var match, regex;
+
+        if (getUtility().isUndefinedOrNull(formElement.get(propertyPath))) {
+          return;
+        }
+
         regex = /^\{([a-z0-9-_]+)?\}$/i;
         match = regex.exec(formElement.get(propertyPath));
         if (!match || ((match[1] && !getFormEditorApp().isFormElementIdentifierUsed(match[1])) || !match[1])) {