Skip to content

Conversation

@bjorvack
Copy link
Contributor

Makes it possible to use a custom label for the add button in a collection type

    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add(
                'keys',
                CollectionType::class,
                [
                    'label' => false,
                    'entry_type' => AddKeyType::class,
                    'allow_add' => true,
                    'allow_delete' => true,
                    'add_btn_label' => 'forms.buttons.addKey',
                ]
            );
    }

@bjorvack bjorvack requested a review from a team January 12, 2024 12:19
$resolver->setDefaults(
[
'allow_drag_and_drop' => true,
'add_btn_label' => 'forms.buttons.addItem',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niet beter om het voluit te schrijven? add_button_label

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed bb5275a

{% if allow_add %}
<button type="button" class="btn btn-success btn-sm" data-role="collection-add-button">
<i class="fas fa-plus me-2"></i> {{ 'forms.buttons.addItem'|trans|ucfirst }}
<i class="fas fa-plus me-2"></i> {{ form.vars.add_button_label|trans|ucfirst }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wil die lijn in CollectionTypeExtension niet juist zeggen dat ge dat kunt aanroepen als add_button_label zonder die form.vars?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 78a87a7

@bjorvack bjorvack merged commit f3044db into master Jan 12, 2024
@jonasdekeukelaere jonasdekeukelaere deleted the 287-variable-add-button-label-for-collections branch October 11, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants