mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
create custom fields default group from new layout
This commit is contained in:
parent
41c47df0c3
commit
0dcf2c33f0
@ -41,37 +41,4 @@ class CustomFieldsDefaultGroupController extends Controller
|
|||||||
'form' => $form->createView()
|
'form' => $form->createView()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the CustomField Group with id $cFGroupId as default
|
|
||||||
*/
|
|
||||||
public function setAGroupAsDefaultAction(Request $request)
|
|
||||||
{
|
|
||||||
$cFGroupId = $request->query->get('cFGroup');
|
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findOneById($cFGroupId);
|
|
||||||
|
|
||||||
if(!$cFGroup) {
|
|
||||||
throw new Exception("No CF GROUP with ID".$cFGroupId, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cFDefaultGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsDefaultGroup')
|
|
||||||
->findOneByEntity($cFGroup->getEntity());
|
|
||||||
|
|
||||||
if($cFDefaultGroup) {
|
|
||||||
$em->remove($cFDefaultGroup);
|
|
||||||
$em->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
$newCFDefaultGroup = new CustomFieldsDefaultGroup();
|
|
||||||
$newCFDefaultGroup->setCustomFieldsGroup($cFGroup);
|
|
||||||
$newCFDefaultGroup->setEntity($cFGroup->getEntity());
|
|
||||||
|
|
||||||
$em->persist($newCFDefaultGroup);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('customfieldsdefaultgroup'));
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ use Doctrine\ORM\Query;
|
|||||||
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
|
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
|
||||||
|
use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CustomFieldsGroup controller.
|
* CustomFieldsGroup controller.
|
||||||
@ -70,7 +71,7 @@ class CustomFieldsGroupController extends Controller
|
|||||||
* @param CustomFieldsGroup $group
|
* @param CustomFieldsGroup $group
|
||||||
* @return \Symfony\Component\Form\Form
|
* @return \Symfony\Component\Form\Form
|
||||||
*/
|
*/
|
||||||
private function createMakeDefaultForm(CustomFieldsGroup $group)
|
private function createMakeDefaultForm(CustomFieldsGroup $group = null)
|
||||||
{
|
{
|
||||||
return $this->createFormBuilder($group, array(
|
return $this->createFormBuilder($group, array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
@ -256,9 +257,52 @@ class CustomFieldsGroupController extends Controller
|
|||||||
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
|
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
));
|
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the CustomField Group with id $cFGroupId as default
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
|
||||||
|
return $this->redirect($this->generateUrl('customfieldsgroup'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function render the customFieldsGroup as a form.
|
* This function render the customFieldsGroup as a form.
|
||||||
|
@ -8,7 +8,7 @@ CustomFieldsGroup creation: Nouveau groupe de champs personnalisés
|
|||||||
Entity: Entité
|
Entity: Entité
|
||||||
"Is default ?": "Par défaut ?"
|
"Is default ?": "Par défaut ?"
|
||||||
"Some module select default groups for some usage. Example: the default person group is shown under person page.": "Certains modules sélectionnent en priorité les formulaires par défaut. Exemple: le formulaire par défaut pour une personne est affiché sur la page principale pour la personne"
|
"Some module select default groups for some usage. Example: the default person group is shown under person page.": "Certains modules sélectionnent en priorité les formulaires par défaut. Exemple: le formulaire par défaut pour une personne est affiché sur la page principale pour la personne"
|
||||||
Make default: Assigner comme formulaire par défaut
|
Make default: Rendre groupe par défaut
|
||||||
Create a new group: Créer un nouveau groupe
|
Create a new group: Créer un nouveau groupe
|
||||||
CustomFieldsGroup details: Détail du groupe de champs personnalisés
|
CustomFieldsGroup details: Détail du groupe de champs personnalisés
|
||||||
Fields associated with this group: Champs associés à ce groupe
|
Fields associated with this group: Champs associés à ce groupe
|
||||||
|
Loading…
x
Reference in New Issue
Block a user