Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin/revision): collection enter key triggers delete first item #954

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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