[英]I can't access of Collection Type Radio Button's values in jQuery
A basic Form Type in Symfony 4 with "simple fields" (like TextType..) and one CollectionType. Symfony 4中的基本表单类型,带有“简单字段”(如TextType ..)和一个CollectionType。
How can I access of Collection Type Radio Button's values in jQuery? 如何在jQuery中访问Collection Type单选按钮的值?
To get the value of "simple field", I do that in jQuery: 为了获得“简单字段”的值,我在jQuery中这样做:
$('#divfield').click( function() { ... } );
ok no problem 好吧没问题
but the same thing with a field that is in collectionType: 但与collectionType中的字段相同:
$('#divInCollectionType').click( function() { ... } );
IMPOSSIBLE , I can't select any div or class that is in data-prototype.... 不可能,我不能选择数据原型中的任何div或类....
FormType "User":
->add('tel_contact')
->add('struct', CollectionType::class, array(
'entry_type' => StructureType::class,
'data_class' => null,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'prototype' => true,
))
FormType "StructureType":
->add('category', EntityType::class, array(
'class' => Category::class,
'choices' => ...,
'choice_label' => 'nom_cate',
'expanded' => true,
'choice_value' => null,
'attr' => ['class' => 'categories']
))
I just want, for instance, dynamically display the name of the category checked when the group of radioButton change ... It's so easy but I don't know why with the collectionType it does not work ! 我只想要,例如,当radioButton组改变时,动态显示所检查类别的名称...这很容易,但我不知道为什么使用collectionType它不起作用!
As there is no element in your collection when your form is displayed, you can't target directly a div from your collection prototype. 由于在显示表单时集合中没有元素,因此您无法直接从集合原型中定位div。 I suggest you to try something like $(document).on('click', '#divInCollectionType', function() {...})
我建议你尝试类似$(document).on('click', '#divInCollectionType', function() {...})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.