Skip to content

Commit

Permalink
[BUGFIX] Use page layout specific column labels
Browse files Browse the repository at this point in the history
Labels of columns in page layouts were only translatable with the generic
non-specific key "flux.grid.columns.$columnName".

This patch sets the page layout's grid parent object to be the page layout's form,
so that the resolved parent ID is that of the form.

A column named "one" within a page layout with id "twocol" will thus get
the label key "flux.twocol.columns.one", just as it was for flux 8.

If the backend layout cannot be found because the page template file does
not exist anymore, we need to return NULL from buildBackendLayout()
to get a proper error message.

Resolves: #1468
  • Loading branch information
cweiske committed Jan 27, 2022
1 parent 3cc5047 commit cc57934
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/Form/Container/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function buildExtendedBackendLayoutArray(int $parentRecordUid): array
* @param int $parentRecordUid
* @return BackendLayout
*/
public function buildBackendLayout(int $parentRecordUid): BackendLayout
public function buildBackendLayout(int $parentRecordUid): ?BackendLayout
{
$configuration = $this->buildBackendLayoutArray($parentRecordUid);
$configuration = $this->ensureDottedKeys($configuration);
Expand All @@ -153,9 +153,12 @@ public function buildBackendLayout(int $parentRecordUid): BackendLayout
foreach ($this->flattenSetup($configuration, 'backend_layout.') as $name => $value) {
$typoScriptString .= $name . ' = ' . $value . LF;
}
if ($root->getName() === null) {
return null;
}
return new BackendLayout(
$this->getRoot()->getName(),
LocalizationUtility::translate($label)
LocalizationUtility::translate($label, $root->getExtensionName())
? $label
: 'LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.grid.grids.grid',
$typoScriptString
Expand Down
4 changes: 4 additions & 0 deletions Classes/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,15 @@ public function getGrid(array $row)
$gridColumn->setColSpan($object['colspan'] ?? 1);
}
}
$grid->setParent($form);
return $grid;
}
}
$grid = $this->grid ?? $this->extractConfiguration($row, 'grids')['grid'] ?? Grid::create();
$grid->setExtensionName($grid->getExtensionName() ?: $this->getControllerExtensionKeyFromRecord($row));
if ($form) {
$grid->setParent($form);
}
return $grid;
}

Expand Down

0 comments on commit cc57934

Please sign in to comment.