From 84662f9e61561a056b9953b0b5c2be5bcae9df1b Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Fri, 25 Oct 2024 08:58:19 +0200 Subject: [PATCH] feat(contentType/field): asset field type add label field (#1055) --- EMS/core-bundle/src/Form/DataField/AssetFieldType.php | 3 +++ EMS/core-bundle/src/Form/Field/AssetType.php | 3 +++ EMS/core-bundle/src/Resources/views/form/fields.html.twig | 1 + .../src/Resources/views/macros/data-field-type.html.twig | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/EMS/core-bundle/src/Form/DataField/AssetFieldType.php b/EMS/core-bundle/src/Form/DataField/AssetFieldType.php index 1abfbccc8..9685ea778 100644 --- a/EMS/core-bundle/src/Form/DataField/AssetFieldType.php +++ b/EMS/core-bundle/src/Form/DataField/AssetFieldType.php @@ -147,6 +147,8 @@ public function buildView(FormView $view, FormInterface $form, array $options): */ public function generateMapping(FieldType $current): array { + $mapping = parent::generateMapping($current); + return [ $current->getName() => \array_merge([ 'type' => 'nested', @@ -160,6 +162,7 @@ public function generateMapping(FieldType $current): array EmsFields::CONTENT_FILE_SIZE_FIELD => $this->elasticsearchService->getLongMapping(), EmsFields::CONTENT_FILE_SIZE_FIELD_ => $this->elasticsearchService->getLongMapping(), EmsFields::CONTENT_IMAGE_RESIZED_HASH_FIELD => $this->elasticsearchService->getKeywordMapping(), + EmsFields::CONTENT_FILE_TITLE => $mapping[$current->getName()], ], ], \array_filter($current->getMappingOptions())), ]; diff --git a/EMS/core-bundle/src/Form/Field/AssetType.php b/EMS/core-bundle/src/Form/Field/AssetType.php index 0187da56e..15903a4dc 100644 --- a/EMS/core-bundle/src/Form/Field/AssetType.php +++ b/EMS/core-bundle/src/Form/Field/AssetType.php @@ -51,6 +51,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'class' => 'name', ], 'required' => $options['required'], + ]) + ->add(EmsFields::CONTENT_FILE_TITLE, TextType::class, [ + 'required' => $options['required'], ]); } } diff --git a/EMS/core-bundle/src/Resources/views/form/fields.html.twig b/EMS/core-bundle/src/Resources/views/form/fields.html.twig index de9e6c127..3a27cabf9 100644 --- a/EMS/core-bundle/src/Resources/views/form/fields.html.twig +++ b/EMS/core-bundle/src/Resources/views/form/fields.html.twig @@ -983,6 +983,7 @@ {{- form_row(fileItem.sha1) -}} {{- form_row(fileItem._image_resized_hash) -}} {{- form_row(fileItem.mimetype) -}} + {{- form_row(fileItem._title) -}}