@@ -44,6 +44,12 @@ public function buildView(FormView $view, FormInterface $form, array $options):
44
44
if ($ form ->getConfig ()->hasAttribute ('button_add_prototype ' )) {
45
45
$ prototype = $ form ->getConfig ()->getAttribute ('button_add_prototype ' );
46
46
$ view ->vars ['button_add_prototype ' ] = $ prototype ->setParent ($ form )->createView ($ view );
47
+
48
+ $ attr = $ view ->vars ['button_add_prototype ' ]->vars ['attr ' ];
49
+ $ attr ['data-action ' ] ??= 'live#action ' ;
50
+ $ attr ['data-action-name ' ] ??= sprintf ('addCollectionItem(name=%s) ' , $ view ->vars ['full_name ' ]);
51
+ $ view ->vars ['button_add_prototype ' ]->vars ['attr ' ] = $ attr ;
52
+
47
53
array_splice ($ view ->vars ['button_add_prototype ' ]->vars ['block_prefixes ' ], 1 , 0 , 'live_collection_button_add ' );
48
54
}
49
55
}
@@ -76,6 +82,12 @@ public function finishView(FormView $view, FormInterface $form, array $options):
76
82
77
83
foreach ($ view as $ k => $ entryView ) {
78
84
$ entryView ->vars ['button_delete_prototype ' ] = $ prototypes [$ k ]->createView ($ entryView );
85
+
86
+ $ attr = $ entryView ->vars ['button_delete_prototype ' ]->vars ['attr ' ];
87
+ $ attr ['data-action ' ] ??= 'live#action ' ;
88
+ $ attr ['data-action-name ' ] ??= sprintf ('removeCollectionItem(name=%s, index=%s) ' , $ view ->vars ['full_name ' ], $ k );
89
+ $ entryView ->vars ['button_delete_prototype ' ]->vars ['attr ' ] = $ attr ;
90
+
79
91
array_splice ($ entryView ->vars ['button_delete_prototype ' ]->vars ['block_prefixes ' ], 1 , 0 , 'live_collection_button_delete ' );
80
92
}
81
93
}
0 commit comments