Skip to content

Commit

Permalink
fix(core/revision): collection enter key triggers delete first item (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Jul 12, 2024
1 parent 489d078 commit abe4ca6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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',
]);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions EMS/core-bundle/src/Resources/views/form/fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,9 @@
<div class="panel-heading ems-handle">
{{ form_label(form) }}
<div class="btn-group pull-right">
{{- form_widget(form.remove_collection_item) -}}
<button type="button" class="btn btn-danger btn-sm remove-content-button">
<span class="fa fa-trash"></span>&nbsp;Remove
</button>
{% if collapsible %}
<div class="pull-right">
<div class="btn-group toggle-group" role="group">
Expand All @@ -631,7 +633,7 @@

<div class="panel-body {% if collapsible %}collapse{% endif %}">
<div class="row">
{% 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']) %}
<div class="{% if child.vars.data.fieldType.options.displayOptions.class is defined %}{{ child.vars.data.fieldType.options.displayOptions.class }}{% endif %}">
{{- form_row(child) -}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion EMS/core-bundle/src/Service/DataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abe4ca6

Please sign in to comment.