symfony 2.1 - Symfony2 GenemuFormBundle collection with Select2 -
symfony 2.1 - Symfony2 GenemuFormBundle collection with Select2 -
i'm trying create bundle collection (many-to-many relationship). i've set collection of info in way:
->add('subcategory', 'genemu_jqueryselect2_entity', array( 'class' => 'coffee\businessbundle\entity\subcategories', 'property' => 'subcategory', 'label' => 'sotto categorie', 'multiple' => true, 'configs' => array( 'placeholder' => 'seleziona almeno una sotto categoria', ) )) ****
in anagrafictype:
->add('subcategories', 'collection', array('type' => new subcategoriestype(), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_name' => '__categ__', 'by_reference' => false ))
in template:
var collectionholder3 = $('ul.categories'); var $addtaglink3 = $('<a href="#" class="add_refer_link">aggiungi</a>'); var $newlinkli3 = $('<li></li>').append($addtaglink3); collectionholder3.append($newlinkli3); function triggerjavascript(id) { $field = $('#' + id); {{ form_javascript(form3.subcategories.vars.prototype, true) }} } function addcatform() { var prototype = collectionholder3.attr('data-prototype'); var newindex = collectionholder3.find('option').length; var newform = prototype.replace(/__categ__/g, newindex); var $newformli = $('<li></li>').append(newform); $newlinkli3.before($newformli); var id = '{{ form3.subcategories.vars.id }}_' + id; triggerjavascript(id); } addcatform(collectionholder3, $newlinkli3); //.. <ul class="categories" data-prototype="{{ form_widget(form3.subcategories.get('prototype')) | e }}"> </ul>
why error?
an exception has been thrown during rendering of template ("unable render form none of next blocks exist: "_my_businessbundle_anagraficatype_subcategories_entry_javascript_prototype", "subcategories_javascript_prototype", "form_javascript_prototype".") in..
where wrong in configuration?
this not solve problem reply question is:
i contacted creator of bundle , bug in bundle, bundle unfortunately suffers several bugs, solution remove , utilize select2 manually.
symfony2 symfony-2.1 symfony-forms
Comments
Post a Comment