Skip to content

Commit

Permalink
[FEATURE] Add "forField" as view variable when extracting form
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NamelessCoder committed Sep 23, 2024
1 parent 150b42c commit 1fa7715
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Classes/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Tests/Unit/Content/RuntimeDefinedContentProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public function testGetTemplateVariables(): void
$expected = [
'record' => $record,
'settings' => [],
'forField' => null,
'page' => [],
'user' => [],
'contentType' => $this->contentTypeDefinition,
Expand Down

0 comments on commit 1fa7715

Please sign in to comment.