From 91128d273085a3b4435b1b58094aad8dc70bbc86 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Mon, 13 Jul 2015 22:20:09 +0200
Subject: [PATCH] [!!!][TASK] TCA: Remove wizard _HIDDENFIELD and hideParent

The functionality provided by _HIDDENFIELD and hideParent on TCA
wizard level can be better realized with the new renderType
registration provided by the NodeFactory. A search showed that
not a single TER extension used the two options, and it is probably
also used very rarely in other 3rd party extensions. It is dropped
now without substitution.

Resolves: #68092
Releases: master
Change-Id: I95fb96561e1879e302ba927d70d72bd454b7fa15
Reviewed-on: http://review.typo3.org/41150
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
---
 .../Form/Element/AbstractFormElement.php      | 26 +---------
 .../Classes/Form/Element/GroupElement.php     |  6 +--
 .../Classes/Form/Element/InputElement.php     |  7 +--
 .../Form/Element/SelectCheckBoxElement.php    |  3 +-
 .../SelectMultipleSideBySideElement.php       |  3 +-
 .../Form/Element/SelectSingleBoxElement.php   |  3 +-
 .../Form/Element/SelectSingleElement.php      |  3 +-
 .../Form/Element/SelectTreeElement.php        |  3 +-
 .../Classes/Form/Element/TextElement.php      |  4 +-
 ...eaking-68092-TcaRemoveWizardHideParent.rst | 49 +++++++++++++++++++
 .../Classes/Form/Element/RichTextElement.php  |  5 +-
 11 files changed, 59 insertions(+), 53 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-68092-TcaRemoveWizardHideParent.rst

diff --git a/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php b/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
index 8001442602d9..b3c681e145b4 100644
--- a/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
@@ -101,7 +101,7 @@ abstract class AbstractFormElement extends AbstractNode {
 	/**
 	 * Rendering wizards for form fields.
 	 *
-	 * @param array $itemKinds Array with the real item in the first value, and an alternative item in the second value.
+	 * @param array $itemKinds Array with the real item in the first value
 	 * @param array $wizConf The "wizard" key from the config array for the field (from TCA)
 	 * @param string $table Table name
 	 * @param array $row The record array
@@ -405,34 +405,10 @@ abstract class AbstractFormElement extends AbstractNode {
 					$otherWizards[] = $suggestWizard->renderSuggestSelector($PA['itemFormElName'], $table, $field, $row, $PA);
 					break;
 			}
-
-			// Hide the real form element?
-			if (is_array($wizardConfiguration['hideParent']) || $wizardConfiguration['hideParent']) {
-				// Setting the item to a hidden-field.
-				$item = $itemKinds[1];
-				if (is_array($wizardConfiguration['hideParent'])) {
-					$options = $this->globalOptions;
-					$options['parameterArray'] = array(
-						'fieldConf' => array(
-							'config' => $wizardConfiguration['hideParent'],
-						),
-						'itemFormElValue' => $PA['itemFormElValue'],
-					);
-					$options['renderType'] = 'none';
-					/** @var NodeFactory $nodeFactory */
-					$nodeFactory = $this->globalOptions['nodeFactory'];
-					$noneElementResult = $nodeFactory->create($options)->render();
-					$item .= $noneElementResult['html'];
-				}
-			}
 		}
 
 		// For each rendered wizard, put them together around the item.
 		if (!empty($buttonWizards) || !empty($otherWizards)) {
-			if ($wizConf['_HIDDENFIELD']) {
-				$item = $itemKinds[1];
-			}
-
 			$innerContent = '';
 			if (!empty($buttonWizards)) {
 				$innerContent .= '<div class="btn-group' . ($wizConf['_VERTICAL'] ? ' btn-group-vertical' : '') . '">' . implode('', $buttonWizards) . '</div>';
diff --git a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
index c3278fd5a8e4..ab34e4e9c94e 100644
--- a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
@@ -324,13 +324,9 @@ class GroupElement extends AbstractFormElement {
 				break;
 		}
 		// Wizards:
-		$altItem = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
 		if (!$disabled) {
 			$html = $this->renderWizards(
-				array(
-					$html,
-					$altItem
-				),
+				array($html),
 				$config['wizards'],
 				$table,
 				$row,
diff --git a/typo3/sysext/backend/Classes/Form/Element/InputElement.php b/typo3/sysext/backend/Classes/Form/Element/InputElement.php
index 8186a772ee88..bb319c6137f7 100644
--- a/typo3/sysext/backend/Classes/Form/Element/InputElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/InputElement.php
@@ -228,14 +228,9 @@ class InputElement extends AbstractFormElement {
 				</div>';
 		}
 
-		// Creating an alternative item without the JavaScript handlers.
-		$altItem = '
-			<input type="hidden" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '_hr" value="" />
-			<input type="hidden" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
-
 		// Wrap a wizard around the item?
 		$html = $this->renderWizards(
-			array($html, $altItem),
+			array($html),
 			$config['wizards'],
 			$table,
 			$row,
diff --git a/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php b/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
index 0c2bd924c572..a24dc3e54aca 100644
--- a/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
@@ -61,8 +61,7 @@ class SelectCheckBoxElement extends AbstractFormElement {
 
 		// Wizards:
 		if (!$disabled) {
-			$altItem = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
-			$html = $this->renderWizards(array($html, $altItem), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
+			$html = $this->renderWizards(array($html), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
 		}
 		$this->resultArray['html'] = $html;
 		return $this->resultArray;
diff --git a/typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php b/typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
index 8ac89e3a66fa..0d44f760654e 100644
--- a/typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
@@ -63,8 +63,7 @@ class SelectMultipleSideBySideElement extends AbstractFormElement {
 
 		// Wizards:
 		if (!$disabled) {
-			$altItem = '<input type="hidden" class="t3js-select-hidden-field" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
-			$html = $this->renderWizards(array($html, $altItem), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
+			$html = $this->renderWizards(array($html), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
 		}
 		$this->resultArray['html'] = $html;
 		return $this->resultArray;
diff --git a/typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php b/typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
index cc3ff3735b35..1f0cb89e2ca3 100644
--- a/typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
@@ -62,8 +62,7 @@ class SelectSingleBoxElement extends AbstractFormElement {
 
 		// Wizards:
 		if (!$disabled) {
-			$altItem = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
-			$html = $this->renderWizards(array($html, $altItem), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
+			$html = $this->renderWizards(array($html), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
 		}
 		$this->resultArray['html'] = $html;
 		return $this->resultArray;
diff --git a/typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php b/typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
index 4001e7703ddd..d46fd272f3eb 100644
--- a/typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
@@ -65,8 +65,7 @@ class SelectSingleElement extends AbstractFormElement {
 
 		// Wizards:
 		if (!$disabled) {
-			$altItem = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
-			$html = $this->renderWizards(array($html, $altItem), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
+			$html = $this->renderWizards(array($html), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
 		}
 		$this->resultArray['html'] = $html;
 		return $this->resultArray;
diff --git a/typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php b/typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php
index d697f5fff3ff..b00c90755307 100644
--- a/typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php
@@ -62,8 +62,7 @@ class SelectTreeElement extends AbstractFormElement {
 
 		// Wizards:
 		if (!$disabled) {
-			$altItem = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
-			$html = $this->renderWizards(array($html, $altItem), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
+			$html = $this->renderWizards(array($html), $config['wizards'], $table, $row, $field, $parameterArray, $parameterArray['itemFormElName'], $specConf);
 		}
 		$resultArray['html'] = $html;
 		return $resultArray;
diff --git a/typo3/sysext/backend/Classes/Form/Element/TextElement.php b/typo3/sysext/backend/Classes/Form/Element/TextElement.php
index 7e93bca09a38..36474e9a449f 100644
--- a/typo3/sysext/backend/Classes/Form/Element/TextElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/TextElement.php
@@ -92,8 +92,6 @@ class TextElement extends AbstractFormElement {
 		$evalList = GeneralUtility::trimExplode(',', $config['eval'], TRUE);
 		// "Extra" configuration; Returns configuration for the field based on settings found in the "types" fieldlist. Traditionally, this is where RTE configuration has been found.
 		$specialConfiguration = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']);
-		// Setting up the altItem form field, which is a hidden field containing the value
-		$altItem = '<input type="hidden" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
 		$html = '';
 
 		// Show message, if no RTE (field can only be edited with RTE!)
@@ -178,7 +176,7 @@ class TextElement extends AbstractFormElement {
 
 			// Wrap a wizard around the item?
 			$html = $this->renderWizards(
-				array($html, $altItem),
+				array($html),
 				$config['wizards'],
 				$table,
 				$row,
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-68092-TcaRemoveWizardHideParent.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-68092-TcaRemoveWizardHideParent.rst
new file mode 100644
index 000000000000..7ef98fa8f14c
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-68092-TcaRemoveWizardHideParent.rst
@@ -0,0 +1,49 @@
+=================================================================
+Breaking: #68092 - TCA: Remove wizard hideParent and _HIDDENFIELD
+=================================================================
+
+Description
+===========
+
+Wizards defined in ``TCA`` for display in ``FormEngine`` allowed to hide the "parent"
+field with the configuration options ``_HIDDENFIELD`` on main wizard level, and with
+the ``hideParent`` option for single wizards.
+
+Both options have been dropped.
+
+
+Impact
+======
+
+The configuration options have no effect anymore, the main field will show up.
+
+
+Affected Installations
+======================
+
+A search through the TER code showed not a single extension that used the above options.
+A 3rd party extension is affected if a ``TCA`` column configuration is used like:
+
+.. code-block:: php
+
+	'aField' => array(
+		'config' => array(
+			...
+			'wizards' => array(
+				'_HIDDENFIELD' => TRUE,
+				'aWizard' => array(
+					'hideParent' => array(
+						...
+					),
+				),
+			),
+		),
+	),
+
+
+Migration
+=========
+
+Wizards can not trigger that a main field is not rendered anymore. If this kind of functionality
+is needed, it is recommended to register an own ``renderType`` in the ``NodeFactory`` for this
+type of field instead to route the element rendering to an own class.
\ No newline at end of file
diff --git a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
index 2b209ceca278..46ed9a9a5902 100644
--- a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
+++ b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
@@ -271,10 +271,7 @@ class RichTextElement extends AbstractFormElement {
 		$html = $this->getMainHtml();
 
 		$this->resultArray['html'] = $this->renderWizards(
-			array(
-				$html,
-				'<input type="hidden" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '" value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />',
-			),
+			array($html),
 			$parameterArray['fieldConf']['config']['wizards'],
 			$table,
 			$row,
-- 
GitLab