From e9f36fbefaedb6d9cb25cb2f9130e9d3248ecf12 Mon Sep 17 00:00:00 2001 From: David mattei Date: Fri, 12 Jul 2024 08:51:39 +0200 Subject: [PATCH] fix(core/revision): collection enter key triggers delete first item --- .../src/Form/DataField/CollectionItemFieldType.php | 9 --------- .../src/Resources/views/form/fields.html.twig | 6 ++++-- EMS/core-bundle/src/Service/DataService.php | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/EMS/core-bundle/src/Form/DataField/CollectionItemFieldType.php b/EMS/core-bundle/src/Form/DataField/CollectionItemFieldType.php index dd350525f..6dda88dd5 100644 --- a/EMS/core-bundle/src/Form/DataField/CollectionItemFieldType.php +++ b/EMS/core-bundle/src/Form/DataField/CollectionItemFieldType.php @@ -6,7 +6,6 @@ use EMS\CoreBundle\Entity\FieldType; use EMS\CoreBundle\Form\DataTransformer\DataFieldModelTransformer; use EMS\CoreBundle\Form\DataTransformer\DataFieldViewTransformer; -use EMS\CoreBundle\Form\Field\SubmitEmsType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; @@ -80,14 +79,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ->addModelTransformer(new DataFieldModelTransformer($fieldType, $this->formRegistry)); } } - - $builder->add('remove_collection_item', SubmitEmsType::class, [ - 'attr' => [ - 'class' => 'btn btn-danger btn-sm remove-content-button', - ], - 'label' => 'Remove', - 'icon' => 'fa fa-trash', - ]); } /** 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 1cd62c6e4..0d65c05f2 100644 --- a/EMS/core-bundle/src/Resources/views/form/fields.html.twig +++ b/EMS/core-bundle/src/Resources/views/form/fields.html.twig @@ -616,7 +616,9 @@
{{ form_label(form) }}
- {{- form_widget(form.remove_collection_item) -}} + {% if collapsible %}
@@ -631,7 +633,7 @@
- {% for child in form.iterator|filter(c => c.vars.name not in ['remove_collection_item', '_ems_internal_deleted']) %} + {% for child in form.iterator|filter(c => c.vars.name not in ['_ems_internal_deleted']) %}
{{- form_row(child) -}}
diff --git a/EMS/core-bundle/src/Service/DataService.php b/EMS/core-bundle/src/Service/DataService.php index 1561124be..cd57d7424 100644 --- a/EMS/core-bundle/src/Service/DataService.php +++ b/EMS/core-bundle/src/Service/DataService.php @@ -405,7 +405,7 @@ public function convertInputValues(DataField $dataField): void public static function isInternalField(string $fieldName): bool { - return \in_array($fieldName, ['_ems_internal_deleted', 'remove_collection_item']); + return '_ems_internal_deleted' === $fieldName; } public function generateInputValues(DataField $dataField): void