a small piece of code to automate collectionTypes in symfony
adding additional event-listener to children
just add following row to your head
<script src="./symfony-collection.js"></script>
it will automatically search for elements with the data-prototype attribute.
<div data-prototype="<input name="collection[__name__]"/ value="__name__">"></div>
Following settings currently exists:
Option | Type | Default | Description |
---|---|---|---|
data-index | integer | 0 | set a different start point |
data-placeholder | string | "__name__" | what should be replaced by the index |
data-buttonId | string | none | search for button with id or creates button with id |
data-buttonClasses | string | none | "btn btn-primary", only needed when button gets created |
data-buttonInnerHTML | string | 'add' | what is written inside of the autogenerated button |
data-prototype | string | none | This is required. |
data-addOneByDefault | string | 'true' | 'false' is the other option. adds 1 prototype by default. |