Controller/CustomFieldsGroupController.php
public function makeDefaultAction(Request $request)
    {
        
        $form = $this->createMakeDefaultForm(null);
        $form->handleRequest($request);

        $cFGroupId = $form->get('id')->getData();

        $em = $this->getDoctrine()->getManager();

        $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findOneById($cFGroupId);

        if(!$cFGroup) {
            throw $this
                  ->createNotFoundException("customFieldsGroup not found with "
                        . "id $cFGroupId");
        }

        $cFDefaultGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsDefaultGroup')
            ->findOneByEntity($cFGroup->getEntity());

        if($cFDefaultGroup) {
            $em->remove($cFDefaultGroup);
            $em->flush(); /*this is necessary, if not doctrine
             * will not remove old entity before adding a new one, 
             * and this leads to violation constraint of unique entity
             * in postgresql
             */
        } 
        
        $newCFDefaultGroup = new CustomFieldsDefaultGroup();
        $newCFDefaultGroup->setCustomFieldsGroup($cFGroup);
        $newCFDefaultGroup->setEntity($cFGroup->getEntity());

        $em->persist($newCFDefaultGroup);
        $em->flush();
        
        $this->addFlash('success', $this->get('translator')
                  ->trans("The default custom fields group has been changed"));

        return $this->redirect($this->generateUrl('customfieldsgroup'));
    }
public function makeDefaultAction(Request $request)
    {
        
        $form = $this->createMakeDefaultForm(null);
        $form->handleRequest($request);

        $cFGroupId = $form->get('id')->getData();

        $em = $this->getDoctrine()->getManager();

        $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findOneById($cFGroupId);

        if(!$cFGroup) {
            throw $this
                  ->createNotFoundException("customFieldsGroup not found with "
                        . "id $cFGroupId");
        }

        $cFDefaultGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsDefaultGroup')
            ->findOneByEntity($cFGroup->getEntity());

        if($cFDefaultGroup) {
            $em->remove($cFDefaultGroup);
            $em->flush(); /*this is necessary, if not doctrine
             * will not remove old entity before adding a new one, 
             * and this leads to violation constraint of unique entity
             * in postgresql
             */
        } 
        
        $newCFDefaultGroup = new CustomFieldsDefaultGroup();
        $newCFDefaultGroup->setCustomFieldsGroup($cFGroup);
        $newCFDefaultGroup->setEntity($cFGroup->getEntity());

        $em->persist($newCFDefaultGroup);
        $em->flush();
        
        $this->addFlash('success', $this->get('translator')
                  ->trans("The default custom fields group has been changed"));

        return $this->redirect($this->generateUrl('customfieldsgroup'));
    }
Set the CustomField Group with id $cFGroupId as default