0
이 번들을 콜렉션으로 만들기 위해 노력하고 있습니다 (다 대다 관계). 나는이 방법으로 데이터의 수집을 설정 한 : 내 템플릿에Select2를 사용하는 Symfony2 GenemuFormBundle 콜렉션
->add('subCategories', 'collection', array('type' => new SubCategoriesType(),
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'prototype_name' => '__categ__',
'by_reference' => false
))
: anagraficType에서
->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',
)
))
****
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..
어디에서 구성이 잘못 되었습니까? 이 방법으로 문제가 있지만, 질문에 대한 답변을 해결하지 않는
이
안녕하세요, 저는 동일한 프로블을 가지고 있습니다. select2를 수동으로 양식 컬렉션에 사용하는 코드 데모를 붙여 넣을 수 있습니까? 감사 –