Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Entity/FieldParentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ interface FieldParentInterface
public function setLocale(string $locale): Field;

public function getValue(): ?array;

public function isTranslatable(): bool;
}
18 changes: 18 additions & 0 deletions src/Entity/FieldParentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Bolt\Entity;

use Bolt\Configuration\Content\FieldType;

/**
* Implements the methods of the FieldParentInterface.
*/
Expand All @@ -25,4 +27,20 @@ public function setLocale(?string $locale): Field

return $this;
}

/**
* Override isTranslatable so that if one child definition
* has localize: true, the whole field is considered localizable.
*/
public function isTranslatable(): bool
{
/** @var FieldType $fieldDefinition */
foreach ($this->getDefinition()->get('fields', []) as $fieldDefinition) {
if ($fieldDefinition->get('localize', false)) {
return true;
}
}

return parent::isTranslatable();
}
}