<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/546ff1d4326a3bba9b892b4fd9a3afaf289c67a74cdae5233da3f583f69dbd31/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313639313438392f39383134302f31666531343730632d363731352d313165322d383930352d6462326366383237353936362e706e67"><img src="https://camo.githubusercontent.com/546ff1d4326a3bba9b892b4fd9a3afaf289c67a74cdae5233da3f583f69dbd31/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313639313438392f39383134302f31666531343730632d363731352d313165322d383930352d6462326366383237353936362e706e67" alt="DB 1 " data-canonical-src="https://f.cloud.github.com/assets/1691489/98140/1fe1470c-6715-11e2-8905-db2cf8275966.png" style="max-width: 100%;"></a></p>
<p dir="auto">Check-boxes in that picture establish CategoryGroupAttr relation. that mean if attr 3 is checked than new entity CategoryGroupAttr should be created with category where we currently in and group 1 and attr 3. what's the best way to create that form. right now i do that in CategoryType:</p>
<p dir="auto">$builder-&gt;addEventListener(FormEvents::BIND, function(FormEvent $event) {<br>
$data = $event-&gt;getData();<br>
if(null == $data) return;<br>
$form = $event-&gt;getForm();</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        $data-&gt;removeAllGroupedAttrs();

        foreach ($form-&gt;get('categorilizedGroups') as $categorilizedGroup)
        {

            $group = $categorilizedGroup-&gt;get('group');

            foreach ($group-&gt;get('groupedAttributes') as $groupedAttr)
            {
                $attr = $groupedAttr-&gt;get('attribute');


                if($attr-&gt;get('actived')-&gt;getData())
                {
                    // estabilish relation
                    $categoryGroupAttrReference = new CategoryGroupAttributeRef();
                    $categoryGroupAttrReference-&gt;setAttribute($attr-&gt;getData());
                    $categoryGroupAttrReference-&gt;setGroup($group-&gt;getData());
                    $categoryGroupAttrReference-&gt;setFiltered((bool)$attr-&gt;get('filtered')-&gt;getData());
                    $data-&gt;addGroupedAttribute($categoryGroupAttrReference);
                }
            }

        }
    });"><pre class="notranslate"><code class="notranslate">        $data-&gt;removeAllGroupedAttrs();

        foreach ($form-&gt;get('categorilizedGroups') as $categorilizedGroup)
        {

            $group = $categorilizedGroup-&gt;get('group');

            foreach ($group-&gt;get('groupedAttributes') as $groupedAttr)
            {
                $attr = $groupedAttr-&gt;get('attribute');


                if($attr-&gt;get('actived')-&gt;getData())
                {
                    // estabilish relation
                    $categoryGroupAttrReference = new CategoryGroupAttributeRef();
                    $categoryGroupAttrReference-&gt;setAttribute($attr-&gt;getData());
                    $categoryGroupAttrReference-&gt;setGroup($group-&gt;getData());
                    $categoryGroupAttrReference-&gt;setFiltered((bool)$attr-&gt;get('filtered')-&gt;getData());
                    $data-&gt;addGroupedAttribute($categoryGroupAttrReference);
                }
            }

        }
    });
</code></pre></div>
<p dir="auto">what's the best way to save that form</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/f8afddd76dcad51ea9ebd1cbad7a6cd6fa5fc205573deb1a21bf0fc3108417cb/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313639313438392f39383130392f37636437646536652d363731332d313165322d393061632d3161656231616438626463302e706e67"><img src="https://camo.githubusercontent.com/f8afddd76dcad51ea9ebd1cbad7a6cd6fa5fc205573deb1a21bf0fc3108417cb/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313639313438392f39383130392f37636437646536652d363731332d313165322d393061632d3161656231616438626463302e706e67" alt="DB 1 " data-canonical-src="https://f.cloud.github.com/assets/1691489/98109/7cd7de6e-6713-11e2-90ac-1aeb1ad8bdc0.png" style="max-width: 100%;"></a></p>
<p dir="auto">Check-boxes in that picture establish CategoryGroupAttr relation. that mean if attr 3 is checked than new entity CategoryGroupAttr should be created with category where we currently in and group 1 and attr 3. what's the best way to create that form. right now i do that in CategoryType:</p>
<p dir="auto">$builder-&gt;addEventListener(FormEvents::BIND, function(FormEvent $event) {<br>
$data = $event-&gt;getData();<br>
if(null == $data) return;<br>
$form = $event-&gt;getForm();</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        $data-&gt;removeAllGroupedAttrs();

        foreach ($form-&gt;get('categorilizedGroups') as $categorilizedGroup)
        {

            $group = $categorilizedGroup-&gt;get('group');

            foreach ($group-&gt;get('groupedAttributes') as $groupedAttr)
            {
                $attr = $groupedAttr-&gt;get('attribute');


                if($attr-&gt;get('actived')-&gt;getData())
                {
                    // estabilish relation
                    $categoryGroupAttrReference = new CategoryGroupAttributeRef();
                    $categoryGroupAttrReference-&gt;setAttribute($attr-&gt;getData());
                    $categoryGroupAttrReference-&gt;setGroup($group-&gt;getData());
                    $categoryGroupAttrReference-&gt;setFiltered((bool)$attr-&gt;get('filtered')-&gt;getData());
                    $data-&gt;addGroupedAttribute($categoryGroupAttrReference);
                }
            }

        }
    });"><pre class="notranslate"><code class="notranslate">        $data-&gt;removeAllGroupedAttrs();

        foreach ($form-&gt;get('categorilizedGroups') as $categorilizedGroup)
        {

            $group = $categorilizedGroup-&gt;get('group');

            foreach ($group-&gt;get('groupedAttributes') as $groupedAttr)
            {
                $attr = $groupedAttr-&gt;get('attribute');


                if($attr-&gt;get('actived')-&gt;getData())
                {
                    // estabilish relation
                    $categoryGroupAttrReference = new CategoryGroupAttributeRef();
                    $categoryGroupAttrReference-&gt;setAttribute($attr-&gt;getData());
                    $categoryGroupAttrReference-&gt;setGroup($group-&gt;getData());
                    $categoryGroupAttrReference-&gt;setFiltered((bool)$attr-&gt;get('filtered')-&gt;getData());
                    $data-&gt;addGroupedAttribute($categoryGroupAttrReference);
                }
            }

        }
    });
</code></pre></div>
<p dir="auto">what's the best way to save that form</p>