Symfony2 : Radio buttons in a collection

前端 未结 4 622
说谎
说谎 2021-02-07 13:39

In my application, I created a form using the collection field type :

$builder->add(\'tags\', \'collection\', array(
   \'type\' => new TagTyp         


        
4条回答
  •  孤独总比滥情好
    2021-02-07 14:43

    First thing you should wary about - its that in your scheme if tag become main for one entity it will be main for all entities because the tag store attribute and few entities can be tagged with one tag.

    So simplest decision here is to create new property main_tag near tags in your entity, create hidden field main_tag(with id to Tag Data transformer) in your form and populate and change this field with jQuery(for example set it on tag click or clear on main tag delete)

提交回复
热议问题