OK, this is rather awkward problem. I’m using collection form type in Symfony and after I configure it with
'prototype' => true,
'allow_add' => true
I would expect it to print prototype when I call either one of these in Twig template:
form_rest(form)
form_widget(form.subform.get('prototype'))
The problem is that Symfony prints that prototype only if collection contains at least one element.
Is this a bug I’m not aware of or I’m missing something?
Any idea would be greatly appreciated!
Thanks!
I have updated Symfony to it’s latest stable and prototype is still acting strange:
<div data-prototype="...."></div>DIV‘s attribute above)Since no out-of-box solution exists, I was forced to do
IF–ELSEin my JS. That is, JS first checks fordata-prototypeelement and falls back to other one if it does not exists.As soon as I have some time to spare I will study this behavior and, if it’s turn out to be undesired (as I suspect it is), will report it as a bug…