Skip to content

Commit f3044db

Browse files
author
Bjorn Van Acker
authored
Merge pull request #134 from sumocoders/287-variable-add-button-label-for-collections
Add additional var parameter to use a custom add button label
2 parents 766da7f + 78a87a7 commit f3044db

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Form/Extension/CollectionTypeExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ public function configureOptions(OptionsResolver $resolver): void
2323
$resolver->setDefaults(
2424
[
2525
'allow_drag_and_drop' => true,
26+
'add_button_label' => 'forms.buttons.addItem',
2627
]
2728
);
2829
}
2930

3031
public function buildView(FormView $view, FormInterface $form, array $options): void
3132
{
3233
$view->vars['allow_drag_and_drop'] = $options['allow_drag_and_drop'];
34+
$view->vars['add_button_label'] = $options['add_button_label'];
3335
}
3436
}

templates/Form/fields.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110

111111
{% if allow_add %}
112112
<button type="button" class="btn btn-success btn-sm" data-role="collection-add-button">
113-
<i class="fas fa-plus me-2"></i> {{ 'forms.buttons.addItem'|trans|ucfirst }}
113+
<i class="fas fa-plus me-2"></i> {{ add_button_label|trans|ucfirst }}
114114
</button>
115115
{% endif %}
116116
{% endapply %}

0 commit comments

Comments
 (0)