diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 5ea5766647..8cced0303f 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -385,6 +385,11 @@ parameters:
count: 1
path: src/bundle/Controller/ContentViewController.php
+ -
+ message: "#^Parameter \\#1 \\$fieldTypeIdentifier of method Ibexa\\\\Bundle\\\\AdminUi\\\\Controller\\\\FieldDefinitionController\\:\\:getFieldTypeLabel\\(\\) expects string, string\\|null given\\.$#"
+ count: 1
+ path: src/bundle/Controller/FieldDefinitionController.php
+
-
message: "#^Parameter \\#2 \\$fieldDefinition of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\ContentTypeService\\:\\:updateFieldDefinition\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null given\\.$#"
count: 1
diff --git a/src/bundle/Controller/FieldDefinitionController.php b/src/bundle/Controller/FieldDefinitionController.php
index 26a802b200..a182eae278 100644
--- a/src/bundle/Controller/FieldDefinitionController.php
+++ b/src/bundle/Controller/FieldDefinitionController.php
@@ -19,22 +19,28 @@
use Ibexa\Rest\Message;
use Ibexa\Rest\Server\Controller as RestController;
use Ibexa\Rest\Server\Values;
+use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
final class FieldDefinitionController extends RestController
{
- /** @var \Ibexa\Contracts\Core\Repository\ContentTypeService */
- private $contentTypeService;
+ private ContentTypeService $contentTypeService;
- /** @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface */
- private $urlGenerator;
+ private UrlGeneratorInterface $urlGenerator;
- public function __construct(ContentTypeService $contentTypeService, UrlGeneratorInterface $urlGenerator)
- {
+ private TranslatorInterface $translator;
+
+ public function __construct(
+ ContentTypeService $contentTypeService,
+ UrlGeneratorInterface $urlGenerator,
+ TranslatorInterface $translator
+ ) {
$this->contentTypeService = $contentTypeService;
$this->urlGenerator = $urlGenerator;
+ $this->translator = $translator;
}
public function addFieldDefinitionAction(
@@ -59,7 +65,9 @@ public function addFieldDefinitionAction(
$fieldDefinitionCreateStruct->fieldGroup = $input->fieldGroupIdentifier;
$fieldDefinitionCreateStruct->names = [
- $language->languageCode => 'New field type',
+ $language->languageCode => strtr('New %name%', [
+ '%name%' => $this->getFieldTypeLabel($input->fieldTypeIdentifier),
+ ]),
];
$fieldDefinitionCreateStruct->position = $input->position ?? $this->getNextFieldPosition($contentTypeDraft);
@@ -167,4 +175,19 @@ private function getNextFieldPosition(ContentType $contentType): int
return 0;
}
+
+ /**
+ * Generate a human-readable name for field type identifier.
+ */
+ private function getFieldTypeLabel(string $fieldTypeIdentifier): string
+ {
+ $name = $this->translator->trans(
+ /** @Ignore */
+ $fieldTypeIdentifier . '.name',
+ [],
+ 'ibexa_fieldtypes'
+ );
+
+ return mb_strtolower($name);
+ }
}
diff --git a/src/bundle/Resources/public/js/scripts/admin.contenttype.edit.js b/src/bundle/Resources/public/js/scripts/admin.contenttype.edit.js
index 7598d980ca..2ebeb82d93 100644
--- a/src/bundle/Resources/public/js/scripts/admin.contenttype.edit.js
+++ b/src/bundle/Resources/public/js/scripts/admin.contenttype.edit.js
@@ -459,7 +459,9 @@
const targetContainerGroup = targetContainer.closest('.ibexa-collapse--field-definitions-group');
const targetContainerList = targetContainerGroup.closest('.ibexa-content-type-edit__field-definitions-group-list');
const fieldTemplate = targetContainerList.dataset.template;
- const fieldRendered = fieldTemplate.replace('{{ type }}', currentDraggedItem.dataset.itemIdentifier);
+ const fieldRendered = fieldTemplate
+ .replace('{{ name }}', currentDraggedItem.dataset.itemName.toLowerCase())
+ .replace('{{ type }}', currentDraggedItem.dataset.itemIdentifier);
let draggedItemPosition = [...dragContainerItems].findIndex((item, index, array) => {
return item.classList.contains('ibexa-field-definitions-placeholder') && index < array.length - 1;
});
diff --git a/src/bundle/Resources/translations/ibexa_content_type.en.xliff b/src/bundle/Resources/translations/ibexa_content_type.en.xliff
index 05d3e158d5..86a67900c2 100644
--- a/src/bundle/Resources/translations/ibexa_content_type.en.xliff
+++ b/src/bundle/Resources/translations/ibexa_content_type.en.xliff
@@ -322,8 +322,8 @@
key: content_type.view.edit.content_field_definitions
- New field type
- New field type
+ New {{ name }} ({{ type }})
+ New {{ name }} ({{ type }})
key: content_type.view.edit.default_header
diff --git a/src/bundle/Resources/views/themes/admin/content_type/available_field_types.html.twig b/src/bundle/Resources/views/themes/admin/content_type/available_field_types.html.twig
index f261c181b5..0fbbe01343 100644
--- a/src/bundle/Resources/views/themes/admin/content_type/available_field_types.html.twig
+++ b/src/bundle/Resources/views/themes/admin/content_type/available_field_types.html.twig
@@ -18,6 +18,7 @@
{% for item in field_type_toolbar %}