2013-02-11 105 views
0

我试图使这个捆绑集合(多对多的关系)。 我已经建立了数据集合中这样说:Symfony2 GenemuFormBundle收集与Select2

->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', 
     ) 
    )) 
**** 

在anagraficType:

->add('subCategories', 'collection', array('type' => new SubCategoriesType(), 
       'allow_add' => true, 
       'allow_delete' => true, 
       'prototype' => true, 
       'prototype_name' => '__categ__', 
       'by_reference' => false 
      )) 

在我的模板:

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> 

为什么我得到这个错误?

An exception has been thrown during the rendering of a template 
("Unable to render the form as none of the following blocks exist: 
"_my_businessbundle_anagraficatype_subCategories_entry_javascript_prototype", 
"subCategories_javascript_prototype", "form_javascript_prototype".") in.. 

我在哪里配置错了?

回答

1

这并没有解决问题,而是一个问题的答案是:

我联系了包的创造者,是在包中的错误,这种捆绑不幸患了几个错误受苦,这样的解决办法是删除它并手动使用Select2。

+0

嗨,我有同样的问题,你可以粘贴代码演示手动使用select2在表单集合?谢谢 – 2013-10-18 08:25:20