From f228cdf36b3fd5b49b2e2d0fc3c2aa389b54ff6d Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Thu, 29 Aug 2024 09:10:18 +0200 Subject: [PATCH] admin forms: add information icon for all the localized file types --- .../UploadedFile/UploadedFileFormType.php | 4 + src/Form/MultiLocaleBasicFileUploadType.php | 5 ++ src/Form/MultiLocaleFileUploadType.php | 75 +++++++------------ src/Resources/translations/messages.cs.po | 3 + src/Resources/translations/messages.en.po | 3 + 5 files changed, 41 insertions(+), 49 deletions(-) diff --git a/src/Form/Admin/UploadedFile/UploadedFileFormType.php b/src/Form/Admin/UploadedFile/UploadedFileFormType.php index 0aa90fed8b..1fe80e094f 100644 --- a/src/Form/Admin/UploadedFile/UploadedFileFormType.php +++ b/src/Form/Admin/UploadedFile/UploadedFileFormType.php @@ -37,6 +37,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('names', LocalizedType::class, [ 'required' => false, 'label' => t('Names'), + 'attr' => [ + 'icon' => true, + 'iconTitle' => t('Name in the corresponding locale must be filled-in in order to display the file on the storefront'), + ], 'entry_options' => [ 'required' => false, 'constraints' => [ diff --git a/src/Form/MultiLocaleBasicFileUploadType.php b/src/Form/MultiLocaleBasicFileUploadType.php index 719a8f0899..cdd8dca3f8 100644 --- a/src/Form/MultiLocaleBasicFileUploadType.php +++ b/src/Form/MultiLocaleBasicFileUploadType.php @@ -68,6 +68,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'entry_type' => LocalizedType::class, 'allow_add' => true, 'entry_options' => [ + 'attr' => [ + 'icon' => true, + 'iconTitle' => t('Name in the corresponding locale must be filled-in in order to display the file on the storefront'), + 'iconPlacement' => 'right', + ], 'label' => '', 'entry_options' => [ 'constraints' => [ diff --git a/src/Form/MultiLocaleFileUploadType.php b/src/Form/MultiLocaleFileUploadType.php index 5a758ad03e..8c7ce04089 100644 --- a/src/Form/MultiLocaleFileUploadType.php +++ b/src/Form/MultiLocaleFileUploadType.php @@ -16,59 +16,36 @@ class MultiLocaleFileUploadType extends AbstractType * @param \Symfony\Component\Form\FormBuilderInterface $builder * @param array $options */ - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder - ->add($builder->create('namesIndexedById', CollectionType::class, [ - 'required' => false, - 'entry_type' => LocalizedType::class, - 'allow_add' => true, + $namesOptions = [ + 'required' => false, + 'entry_type' => LocalizedType::class, + 'allow_add' => true, + 'entry_options' => [ + 'label' => '', + 'attr' => [ + 'icon' => true, + 'iconTitle' => t( + 'Name in the corresponding locale must be filled-in in order to display the file on the storefront', + ), + 'iconPlacement' => 'right', + ], 'entry_options' => [ - 'label' => '', - 'entry_options' => [ - 'constraints' => [ - new Constraints\Length([ - 'max' => 255, - 'maxMessage' => 'Name cannot be longer than {{ limit }} characters', - ]), - ], + 'constraints' => [ + new Constraints\Length([ + 'max' => 255, + 'maxMessage' => 'Name cannot be longer than {{ limit }} characters', + ]), ], ], - ]))->add( - $builder->create('names', CollectionType::class, [ - 'required' => false, - 'entry_type' => LocalizedType::class, - 'allow_add' => true, - 'entry_options' => [ - 'label' => '', - 'entry_options' => [ - 'constraints' => [ - new Constraints\Length([ - 'max' => 255, - 'maxMessage' => 'Name cannot be longer than {{ limit }} characters', - ]), - ], - ], - ], - ]), - )->add( - $builder->create('relationsNames', CollectionType::class, [ - 'required' => false, - 'entry_type' => LocalizedType::class, - 'allow_add' => true, - 'entry_options' => [ - 'label' => '', - 'entry_options' => [ - 'constraints' => [ - new Constraints\Length([ - 'max' => 255, - 'maxMessage' => 'Name cannot be longer than {{ limit }} characters', - ]), - ], - ], - ], - ]), - ); + ], + ]; + + $builder + ->add($builder->create('namesIndexedById', CollectionType::class, $namesOptions)) + ->add($builder->create('names', CollectionType::class, $namesOptions)) + ->add($builder->create('relationsNames', CollectionType::class, $namesOptions)); } public function getParent() diff --git a/src/Resources/translations/messages.cs.po b/src/Resources/translations/messages.cs.po index 939e01f0b7..a8e180f821 100644 --- a/src/Resources/translations/messages.cs.po +++ b/src/Resources/translations/messages.cs.po @@ -2143,6 +2143,9 @@ msgstr "Název" msgid "Name %locale%" msgstr "Název %locale%" +msgid "Name in the corresponding locale must be filled-in in order to display the file on the storefront" +msgstr "Pro zobrazení souboru na doméně musí být vyplněn název v odpovídajícím jazyce" + msgid "Name serves only for internal use within the administration" msgstr "Název slouží pouze pro interní použití v rámci administrace" diff --git a/src/Resources/translations/messages.en.po b/src/Resources/translations/messages.en.po index 29e304fcb3..f5b2d99f74 100644 --- a/src/Resources/translations/messages.en.po +++ b/src/Resources/translations/messages.en.po @@ -2143,6 +2143,9 @@ msgstr "" msgid "Name %locale%" msgstr "" +msgid "Name in the corresponding locale must be filled-in in order to display the file on the storefront" +msgstr "" + msgid "Name serves only for internal use within the administration" msgstr ""