From 1fa771571c2afb9e8e3928c865dc3e36f75f3be9 Mon Sep 17 00:00:00 2001 From: Claus Due Date: Mon, 23 Sep 2024 16:07:07 +0200 Subject: [PATCH] [FEATURE] Add "forField" as view variable when extracting form Allows templates to make conditions etc. on the current TCA field context. Useful for page templates which have two TCA fields with Flux forms as DS. --- Classes/Provider/AbstractProvider.php | 3 ++- Tests/Unit/Content/RuntimeDefinedContentProviderTest.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/Provider/AbstractProvider.php b/Classes/Provider/AbstractProvider.php index 3c49137d8..78bda7992 100644 --- a/Classes/Provider/AbstractProvider.php +++ b/Classes/Provider/AbstractProvider.php @@ -177,7 +177,8 @@ protected function getViewVariables(array $row, ?string $forField = null): array $fieldName = $forField ?? $this->getFieldName($row); $variables = [ 'record' => $row, - 'settings' => $this->typoScriptService->getSettingsForExtensionName($extensionKey) + 'settings' => $this->typoScriptService->getSettingsForExtensionName($extensionKey), + 'forField' => $forField, ]; // Special case: when saving a new record variable $row[$fieldName] is already an array diff --git a/Tests/Unit/Content/RuntimeDefinedContentProviderTest.php b/Tests/Unit/Content/RuntimeDefinedContentProviderTest.php index 01a840499..b6b62129c 100644 --- a/Tests/Unit/Content/RuntimeDefinedContentProviderTest.php +++ b/Tests/Unit/Content/RuntimeDefinedContentProviderTest.php @@ -179,6 +179,7 @@ public function testGetTemplateVariables(): void $expected = [ 'record' => $record, 'settings' => [], + 'forField' => null, 'page' => [], 'user' => [], 'contentType' => $this->contentTypeDefinition,