我正在尝试使这个捆绑包成为一个集合(多对多关系)。我以这种方式建立了一个数据集合:
->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',
)
))
****
在 anagrafic 类型中:
->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..
我的配置哪里错了?