2013-02-11 108 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