From b6d55de643899cd1cd1b621ed6ae247d9a819f21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Frank=20Na=CC=88gler?= <frank.naegler@typo3.org>
Date: Mon, 16 Nov 2015 11:44:28 +0100
Subject: [PATCH] [BUGFIX] Flexform: Removing section element with empty
 required field

Resolves: #71323
Releases: master
Change-Id: I7836db48d33887c15d1a41bacba0d9fb02fd3a78
Reviewed-on: https://review.typo3.org/44732
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Resources/Public/JavaScript/FormEngineFlexForm.js  |  1 +
 .../Public/JavaScript/FormEngineValidation.js          | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineFlexForm.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineFlexForm.js
index 47cf87fb6571..1d97b3e3c700 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineFlexForm.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineFlexForm.js
@@ -94,6 +94,7 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($) {
 					if (window.confirm('Are you sure?')) {
 						$(this).closest(opts.sectionSelector).hide().addClass(opts.sectionDeletedClass);
 						me.setActionStatus();
+						TYPO3.FormEngine.Validation.validate();
 					}
 				});
 
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
index 9cc55e2d90e1..321e8cd8c5f4 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
@@ -472,10 +472,12 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($, FormEngine) {
 
 		$(FormEngineValidation.rulesSelector).each(function() {
 			var $field = $(this);
-			var newValue = FormEngineValidation.validateField($field);
-			if (newValue.length && $field.val() !== newValue) {
-				$field.attr('value', newValue);
-				FormEngineValidation.setCaretPosition($field, 0);
+			if (!$field.closest('.t3js-flex-section-deleted').length) {
+				var newValue = FormEngineValidation.validateField($field);
+				if (newValue.length && $field.val() !== newValue) {
+					$field.attr('value', newValue);
+					FormEngineValidation.setCaretPosition($field, 0);
+				}
 			}
 		});
 	};
-- 
GitLab