diff --git a/.gitignore b/.gitignore
index 52d2b6ff7..b11589291 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,5 @@ src/Chill/CustomFieldsBundle/vendor/*
bootstrap.php.cache
#the file created by composer to store creds
auth.json
+Tests/Fixtures/App/app/config/parameters.yml
+
diff --git a/Controller/CustomFieldController.php b/Controller/CustomFieldController.php
index f9958d70d..46b013f82 100644
--- a/Controller/CustomFieldController.php
+++ b/Controller/CustomFieldController.php
@@ -4,7 +4,6 @@ namespace Chill\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-
use Chill\CustomFieldsBundle\Entity\CustomField;
/**
@@ -14,40 +13,6 @@ use Chill\CustomFieldsBundle\Entity\CustomField;
class CustomFieldController extends Controller
{
- /**
- * Lists all CustomField entities.
- *
- */
- public function indexAction()
- {
- $em = $this->getDoctrine()->getManager();
-
- $entities = $em->getRepository('ChillCustomFieldsBundle:CustomField')->findAll();
-
- //prepare form for new custom type
- $fieldChoices = array();
- foreach ($this->get('chill.custom_field.provider')->getAllFields()
- as $key => $customType) {
- $fieldChoices[$key] = $customType->getName();
- }
- $form = $this->get('form.factory')
- ->createNamedBuilder(null, 'form', null, array(
- 'method' => 'GET',
- 'action' => $this->generateUrl('customfield_new'),
- 'csrf_protection' => false
- ))
- ->add('type', 'choice', array(
- 'choices' => $fieldChoices
- ))
- ->getForm();
-
- return $this->render('ChillCustomFieldsBundle:CustomField:index.html.twig', array(
- 'entities' => $entities,
- 'form' => $form->createView()
- ));
- }
-
-
/**
* Creates a new CustomField entity.
*
@@ -62,9 +27,16 @@ class CustomFieldController extends Controller
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
+
+ $this->addFlash('success', $this->get('translator')
+ ->trans('The custom field has been created'));
- return $this->redirect($this->generateUrl('customfield_show', array('id' => $entity->getId())));
- }
+ return $this->redirect($this->generateUrl('customfieldsgroup_show',
+ array('id' => $entity->getCustomFieldsGroup()->getId())));
+ }
+
+ $this->addFlash('error', $this->get('translator')
+ ->trans("The custom field form contains errors"));
return $this->render('ChillCustomFieldsBundle:CustomField:new.html.twig', array(
'entity' => $entity,
@@ -85,9 +57,10 @@ class CustomFieldController extends Controller
'action' => $this->generateUrl('customfield_create',
array('type' => $type)),
'method' => 'POST',
- 'type' => $type
+ 'type' => $type,
+ 'group_widget' => ($entity->getCustomFieldsGroup()) ? 'hidden' :'entity'
));
-
+
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
@@ -100,6 +73,21 @@ class CustomFieldController extends Controller
public function newAction(Request $request)
{
$entity = new CustomField();
+
+ //add the custom field group if defined in URL
+ $cfGroupId = $request->query->get('customFieldsGroup', null);
+
+ if ($cfGroupId !== null) {
+ $cfGroup = $this->getDoctrine()->getManager()
+ ->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
+ ->find($cfGroupId);
+ if (!$cfGroup) {
+ throw $this->createNotFoundException('CustomFieldsGroup with id '
+ . $cfGroupId.' is not found !');
+ }
+ $entity->setCustomFieldsGroup($cfGroup);
+ }
+
$form = $this->createCreateForm($entity, $request->query->get('type'));
return $this->render('ChillCustomFieldsBundle:CustomField:new.html.twig', array(
@@ -111,6 +99,7 @@ class CustomFieldController extends Controller
/**
* Finds and displays a CustomField entity.
*
+ * @deprecated is not used since there is no link to show action
*/
public function showAction($id)
{
@@ -122,12 +111,8 @@ class CustomFieldController extends Controller
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
- $deleteForm = $this->createDeleteForm($id);
-
return $this->render('ChillCustomFieldsBundle:CustomField:show.html.twig', array(
- 'entity' => $entity,
- 'delete_form' => $deleteForm->createView(),
- ));
+ 'entity' => $entity, ));
}
/**
@@ -145,12 +130,10 @@ class CustomFieldController extends Controller
}
$editForm = $this->createEditForm($entity, $entity->getType());
- $deleteForm = $this->createDeleteForm($id);
-
+
return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
));
}
@@ -166,7 +149,8 @@ class CustomFieldController extends Controller
$form = $this->createForm('custom_field_choice', $entity, array(
'action' => $this->generateUrl('customfield_update', array('id' => $entity->getId())),
'method' => 'PUT',
- 'type' => $type
+ 'type' => $type,
+ 'group_widget' => 'hidden'
));
$form->add('submit', 'submit', array('label' => 'Update'));
@@ -187,61 +171,24 @@ class CustomFieldController extends Controller
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
- $deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity, $entity->getType());
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
+
+ $this->addFlash('success', $this->get('translator')
+ ->trans("The custom field has been updated"));
return $this->redirect($this->generateUrl('customfield_edit', array('id' => $id)));
}
+
+ $this->addFlash('error', $this->get('translator')
+ ->trans("The custom field form contains errors"));
return $this->render('ChillCustomFieldsBundle:CustomField:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
));
}
- /**
- * Deletes a CustomField entity.
- *
- */
- public function deleteAction(Request $request, $id)
- {
- $form = $this->createDeleteForm($id);
- $form->handleRequest($request);
-
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('ChillCustomFieldsBundle:CustomField')->find($id);
-
- if (!$entity) {
- throw $this->createNotFoundException('Unable to find CustomField entity.');
- }
-
- $em->remove($entity);
- $em->flush();
- }
-
- return $this->redirect($this->generateUrl('customfield'));
- }
-
- /**
- * Creates a form to delete a CustomField entity by id.
- *
- * @param mixed $id The entity id
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createDeleteForm($id)
- {
- return $this->createFormBuilder()
- ->setAction($this->generateUrl('customfield_delete', array('id' => $id)))
- ->setMethod('DELETE')
- ->add('submit', 'submit', array('label' => 'Delete'))
- ->getForm()
- ;
- }
-
}
diff --git a/Controller/CustomFieldsDefaultGroupController.php b/Controller/CustomFieldsDefaultGroupController.php
deleted file mode 100644
index 860d3c554..000000000
--- a/Controller/CustomFieldsDefaultGroupController.php
+++ /dev/null
@@ -1,77 +0,0 @@
-getDoctrine()->getManager();
-
- $defaultGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsDefaultGroup')->findAll();
-
- $form = $this->get('form.factory')
- ->createNamedBuilder(null, 'form', null, array(
- 'method' => 'GET',
- 'action' => $this->generateUrl('customfieldsdefaultgroup_set'),
- 'csrf_protection' => false
- ))
- ->add('cFGroup', 'entity', array(
- 'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup',
- 'property' => 'name[fr]'
- ))
- ->getForm();
-
- return $this->render('ChillCustomFieldsBundle:CustomFieldsDefaultGroup:list.html.twig', array(
- 'defaultGroups' => $defaultGroups,
- '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'));
- }
-}
\ No newline at end of file
diff --git a/Controller/CustomFieldsGroupController.php b/Controller/CustomFieldsGroupController.php
index 9897da5f4..46b95fd5a 100644
--- a/Controller/CustomFieldsGroupController.php
+++ b/Controller/CustomFieldsGroupController.php
@@ -4,8 +4,11 @@ namespace Chill\CustomFieldsBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-
+use Doctrine\ORM\Query;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
+use Chill\CustomFieldsBundle\Entity\CustomField;
+use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
+use Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup;
/**
* CustomFieldsGroup controller.
@@ -22,12 +25,64 @@ class CustomFieldsGroupController extends Controller
{
$em = $this->getDoctrine()->getManager();
- $entities = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findAll();
+ $cfGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findAll();
+ $defaultGroups = $this->getDefaultGroupsId();
+
+ $makeDefaultFormViews = array();
+ foreach ($cfGroups as $group) {
+ if (!in_array($group->getId(), $defaultGroups)){
+ $makeDefaultFormViews[$group->getId()] = $this->createMakeDefaultForm($group)->createView();
+ }
+ }
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:index.html.twig', array(
- 'entities' => $entities,
+ 'entities' => $cfGroups,
+ 'default_groups' => $defaultGroups,
+ 'make_default_forms' => $makeDefaultFormViews
));
}
+
+ /**
+ * Get an array of CustomFieldsGroupId which are marked as default
+ * for their entity
+ *
+ * @return int[]
+ */
+ private function getDefaultGroupsId()
+ {
+ $em = $this->getDoctrine()->getManager();
+
+ $customFieldsGroupIds = $em->createQuery('SELECT g.id FROM '
+ . 'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d '
+ . 'JOIN d.customFieldsGroup g')
+ ->getResult(Query::HYDRATE_SCALAR);
+
+ $result = array();
+ foreach ($customFieldsGroupIds as $row) {
+ $result[] = $row['id'];
+ }
+
+ return $result;
+ }
+
+ /**
+ * create a form to make the group default
+ *
+ * @param CustomFieldsGroup $group
+ * @return \Symfony\Component\Form\Form
+ */
+ private function createMakeDefaultForm(CustomFieldsGroup $group = null)
+ {
+ return $this->createFormBuilder($group, array(
+ 'method' => 'POST',
+ 'action' => $this->generateUrl('customfieldsgroup_makedefault')
+ ))
+ ->add('id', 'hidden')
+ ->add('submit', 'submit', array('label' => 'Make default'))
+ ->getForm();
+ }
+
+
/**
* Creates a new CustomFieldsGroup entity.
*
@@ -42,9 +97,15 @@ class CustomFieldsGroupController extends Controller
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
+
+ $this->addFlash('success', $this->get('translator')
+ ->trans("The custom fields group has been created"));
return $this->redirect($this->generateUrl('customfieldsgroup_show', array('id' => $entity->getId())));
}
+
+ $this->addFlash('error', $this->get('translator')
+ ->trans("The custom fields group form contains errors"));
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:new.html.twig', array(
'entity' => $entity,
@@ -99,14 +160,36 @@ class CustomFieldsGroupController extends Controller
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
-
- $deleteForm = $this->createDeleteForm($id);
+
+ $options = $this->getOptionsAvailable($entity->getEntity());
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:show.html.twig', array(
'entity' => $entity,
- 'delete_form' => $deleteForm->createView(),
+ 'create_field_form' => $this->createCreateFieldForm($entity)->createView(),
+ 'options' => $options
));
}
+
+ /**
+ * Return an array of available key option for custom fields group
+ * on the given entity
+ *
+ * @param string $entity the entity to filter
+ */
+ private function getOptionsAvailable($entity)
+ {
+ $options = $this->getParameter('chill_custom_fields.'
+ . 'customizables_entities');
+
+ foreach($options as $key => $definition) {
+ if ($definition['class'] == $entity) {
+ foreach ($definition['options'] as $key => $value) {
+ yield $key;
+ }
+ }
+ }
+ // [$entity->getEntity()];
+ }
/**
* Displays a form to edit an existing CustomFieldsGroup entity.
@@ -123,12 +206,10 @@ class CustomFieldsGroupController extends Controller
}
$editForm = $this->createEditForm($entity);
- $deleteForm = $this->createDeleteForm($id);
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
));
}
@@ -149,6 +230,37 @@ class CustomFieldsGroupController extends Controller
return $form;
}
+
+ private function createCreateFieldForm(CustomFieldsGroup $customFieldsGroup)
+ {
+
+ $fieldChoices = array();
+ foreach ($this->get('chill.custom_field.provider')->getAllFields()
+ as $key => $customType) {
+ $fieldChoices[$key] = $customType->getName();
+ }
+
+ $customfield = (new CustomField())
+ ->setCustomFieldsGroup($customFieldsGroup);
+
+ $builder = $this->get('form.factory')
+ ->createNamedBuilder(null, 'form', $customfield, array(
+ 'method' => 'GET',
+ 'action' => $this->generateUrl('customfield_new'),
+ 'csrf_protection' => false
+ ))
+ ->add('type', 'choice', array(
+ 'choices' => $fieldChoices
+ ))
+ ->add('customFieldsGroup', 'hidden')
+ ->add('submit', 'submit');
+ $builder->get('customFieldsGroup')
+ ->addViewTransformer(new CustomFieldsGroupToIdTransformer(
+ $this->getDoctrine()->getManager()));
+
+ return $builder->getForm();
+ }
+
/**
* Edits an existing CustomFieldsGroup entity.
*
@@ -163,61 +275,72 @@ class CustomFieldsGroupController extends Controller
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
- $deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
+
+ $this->addFlash('success', $this->get('translator')
+ ->trans("The custom fields group has been updated"));
return $this->redirect($this->generateUrl('customfieldsgroup_edit', array('id' => $id)));
}
+
+ $this->addFlash('error', $this->get('translator')
+ ->trans("The custom fields group form contains errors"));
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
- 'delete_form' => $deleteForm->createView(),
- ));
+
+ ));
}
+
/**
- * Deletes a CustomFieldsGroup entity.
- *
+ * Set the CustomField Group with id $cFGroupId as default
*/
- public function deleteAction(Request $request, $id)
+ public function makeDefaultAction(Request $request)
{
- $form = $this->createDeleteForm($id);
+
+ $form = $this->createMakeDefaultForm(null);
$form->handleRequest($request);
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($id);
+ $cFGroupId = $form->get('id')->getData();
- if (!$entity) {
- throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
- }
+ $em = $this->getDoctrine()->getManager();
- $em->remove($entity);
- $em->flush();
+ $cFGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findOneById($cFGroupId);
+
+ if(!$cFGroup) {
+ throw $this
+ ->createNotFoundException("customFieldsGroup not found with "
+ . "id $cFGroupId");
}
- return $this->redirect($this->generateUrl('customfieldsgroup'));
- }
+ $cFDefaultGroup = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsDefaultGroup')
+ ->findOneByEntity($cFGroup->getEntity());
- /**
- * Creates a form to delete a CustomFieldsGroup entity by id.
- *
- * @param mixed $id The entity id
- *
- * @return \Symfony\Component\Form\Form The form
- */
- private function createDeleteForm($id)
- {
- return $this->createFormBuilder()
- ->setAction($this->generateUrl('customfieldsgroup_delete', array('id' => $id)))
- ->setMethod('DELETE')
- ->add('submit', 'submit', array('label' => 'Delete'))
- ->getForm()
- ;
+ 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'));
}
/**
@@ -258,7 +381,7 @@ class CustomFieldsGroupController extends Controller
}
var_dump($form->getData());
- var_dump(json_encode($form->getData()));
+ var_dump(json_enccode($form->getData()));
}
diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php
index a20eb4814..304b33ef3 100644
--- a/CustomFields/CustomFieldChoice.php
+++ b/CustomFields/CustomFieldChoice.php
@@ -136,7 +136,8 @@ class CustomFieldChoice implements CustomFieldInterface
'choices' => array(
1 => 'Multiple',
0 => 'Unique'),
- 'empty_data' => 0
+ 'empty_data' => 0,
+ 'label' => 'Multiplicity'
))
->add(self::EXPANDED, 'choice', array(
'expanded' => true,
@@ -144,7 +145,8 @@ class CustomFieldChoice implements CustomFieldInterface
'choices' => array(
1 => 'Expanded',
0 => 'Non expanded'),
- 'empty_data' => 0
+ 'empty_data' => 0,
+ 'label' => 'Choice display'
))
->add(self::ALLOW_OTHER, 'choice', array(
'label' => 'Allow other',
diff --git a/CustomFields/CustomFieldText.php b/CustomFields/CustomFieldText.php
index 08e4ab58f..a11705707 100644
--- a/CustomFields/CustomFieldText.php
+++ b/CustomFields/CustomFieldText.php
@@ -122,7 +122,13 @@ class CustomFieldText implements CustomFieldInterface
return $builder
->add(self::MAX_LENGTH, 'integer', array('empty_data' => 256))
->add(self::MULTIPLE_CF_INLINE, 'choice', array(
- 'choices' => array('1' => 'True', '0' => 'False')))
+ 'choices' => array(
+ '1' => 'Multiple boxes on the line',
+ '0' => 'One box on the line'
+ ),
+ 'label' => 'Box appearance',
+ 'expanded' => True
+ ))
;
}
}
diff --git a/CustomFields/CustomFieldTitle.php b/CustomFields/CustomFieldTitle.php
index 78b6f08d6..6c15543eb 100644
--- a/CustomFields/CustomFieldTitle.php
+++ b/CustomFields/CustomFieldTitle.php
@@ -96,10 +96,13 @@ class CustomFieldTitle implements CustomFieldInterface
public function buildOptionsForm(FormBuilderInterface $builder)
{
return $builder->add(self::TYPE, 'choice',
- array('choices' => array(
- self::TYPE_TITLE => self::TYPE_TITLE,
- self::TYPE_SUBTITLE => self::TYPE_SUBTITLE
- ))
+ array(
+ 'choices' => array(
+ self::TYPE_TITLE => 'Main title',
+ self::TYPE_SUBTITLE => 'Subtitle'
+ ),
+ 'label' => 'Title level'
+ )
);
}
}
diff --git a/Form/CustomFieldType.php b/Form/CustomFieldType.php
index 77d8366c1..7130b8e60 100644
--- a/Form/CustomFieldType.php
+++ b/Form/CustomFieldType.php
@@ -6,9 +6,11 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
-use Chill\CustomFieldsBundle\Entity\CustomField;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
+use Doctrine\Common\Persistence\ObjectManager;
+use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
+
class CustomFieldType extends AbstractType
{
@@ -20,10 +22,17 @@ class CustomFieldType extends AbstractType
private $culture = 'fr';
+ /**
+ * @var ObjectManager
+ */
+ private $om;
- public function __construct(CustomFieldProvider $compiler)
+
+ public function __construct(CustomFieldProvider $compiler,
+ ObjectManager $om)
{
$this->customFieldProvider = $compiler;
+ $this->om = $om;
}
/**
* @param FormBuilderInterface $builder
@@ -40,11 +49,22 @@ class CustomFieldType extends AbstractType
$builder
->add('name', 'translatable_string')
- ->add('active', 'checkbox', array('required' => false))
- ->add('customFieldsGroup', 'entity', array(
+ ->add('active', 'checkbox', array('required' => false));
+
+ if ($options['group_widget'] === 'entity') {
+ $builder->add('customFieldsGroup', 'entity', array(
'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup',
'property' => 'name['.$this->culture.']'
- ))
+ ));
+ } elseif ($options['group_widget'] === 'hidden') {
+ $builder->add('customFieldsGroup', 'hidden');
+ $builder->get('customFieldsGroup')
+ ->addViewTransformer(new CustomFieldsGroupToIdTransformer($this->om));
+ } else {
+ throw new \LogicException('The value of group_widget is not handled');
+ }
+
+ $builder
->add('ordering', 'number')
->add('type', 'hidden', array('data' => $options['type']))
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event)
@@ -80,10 +100,12 @@ class CustomFieldType extends AbstractType
'data_class' => 'Chill\CustomFieldsBundle\Entity\CustomField'
));
- $resolver->setRequired(array('type'))
- ->addAllowedValues(array('type' =>
- array_keys($this->customFieldProvider->getAllFields())
- ));
+ $resolver->setRequired(array('type', 'group_widget'))
+ ->addAllowedValues(array(
+ 'type' => array_keys($this->customFieldProvider->getAllFields()),
+ 'group_widget' => array('hidden', 'entity')
+ ))
+ ->setDefault('group_widget', 'entity');
}
/**
diff --git a/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php b/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
index 662ef42f1..f2dac9b0c 100644
--- a/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
+++ b/Form/DataTransformer/CustomFieldsGroupToIdTransformer.php
@@ -33,6 +33,14 @@ class CustomFieldsGroupToIdTransformer implements DataTransformerInterface
if (null === $customFieldsGroup) {
return "";
}
+
+ if (!$customFieldsGroup instanceof CustomFieldsGroup) {
+ throw new TransformationFailedException(sprintf('Transformation failed: '
+ . 'the expected type of the transforme function is an '
+ . 'object of type Chill\CustomFieldsBundle\Entity\CustomFieldsGroup, '
+ . '%s given (value : %s)', gettype($customFieldsGroup),
+ $customFieldsGroup));
+ }
return $customFieldsGroup->getId();
}
@@ -49,6 +57,14 @@ class CustomFieldsGroupToIdTransformer implements DataTransformerInterface
if (!$id) {
return null;
}
+
+ if ($id instanceof CustomFieldsGroup) {
+ throw new TransformationFailedException(sprintf(
+ 'The transformation failed: the expected argument on '
+ . 'reverseTransform is an object of type int,'
+ . 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup, '
+ . 'given', gettype($id)));
+ }
$customFieldsGroup = $this->om
->getRepository('ChillCustomFieldsBundle:customFieldsGroup')->find($id)
diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml
index 42718a48c..a6b554e69 100644
--- a/Resources/config/routing.yml
+++ b/Resources/config/routing.yml
@@ -5,7 +5,3 @@ chill_customfields_customfieldsgroup:
chill_customfields_customfield:
resource: "@ChillCustomFieldsBundle/Resources/config/routing/customfield.yml"
prefix: /
-
-chill_customfields_customfieldsdefaultgroup:
- resource: "@ChillCustomFieldsBundle/Resources/config/routing/customfieldsdefaultgroup.yml"
- prefix: /
\ No newline at end of file
diff --git a/Resources/config/routing/customfield.yml b/Resources/config/routing/customfield.yml
index 0f8e7b8d3..eabef0fad 100644
--- a/Resources/config/routing/customfield.yml
+++ b/Resources/config/routing/customfield.yml
@@ -8,19 +8,6 @@ customfield_section:
label: "Custom fields configuration"
icons: ['asterisk']
-customfield:
- path: /{_locale}/admin/customfield/list
- defaults: { _controller: "ChillCustomFieldsBundle:CustomField:index" }
- options:
- menus:
- admin_custom_fields:
- order: 1000
- label: "CustomFields List"
-
-customfield_show:
- path: /{_locale}/admin/customfield/{id}/show
- defaults: { _controller: "ChillCustomFieldsBundle:CustomField:show" }
-
customfield_new:
path: /{_locale}/admin/customfield/new
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:new" }
@@ -38,8 +25,3 @@ customfield_update:
path: /{_locale}/admin/customfield/{id}/update
defaults: { _controller: "ChillCustomFieldsBundle:CustomField:update" }
requirements: { _method: post|put }
-
-customfield_delete:
- path: /{_locale}/admin/customfield/{id}/delete
- defaults: { _controller: "ChillCustomFieldsBundle:CustomField:delete" }
- requirements: { _method: post|delete }
diff --git a/Resources/config/routing/customfieldsdefaultgroup.yml b/Resources/config/routing/customfieldsdefaultgroup.yml
deleted file mode 100644
index 9919337af..000000000
--- a/Resources/config/routing/customfieldsdefaultgroup.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-customfieldsdefaultgroup:
- path: /{_locale}/admin/customfieldsdefaultgroup/
- defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsDefaultGroup:list" }
- options:
- menus:
- admin_custom_fields:
- order: 1000
- label: "CustomFields Default Groups : List"
-
-customfieldsdefaultgroup_set:
- path: /{_locale}/admin/customfieldsdefaultgroup/set/group/as/default/
- defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsDefaultGroup:setAGroupAsDefault" }
\ No newline at end of file
diff --git a/Resources/config/routing/customfieldsgroup.yml b/Resources/config/routing/customfieldsgroup.yml
index f34e0169b..446a15aa3 100644
--- a/Resources/config/routing/customfieldsgroup.yml
+++ b/Resources/config/routing/customfieldsgroup.yml
@@ -10,6 +10,10 @@ customfieldsgroup:
customfieldsgroup_show:
path: /{_locale}/admin/customfieldsgroup/{id}/show
defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsGroup:show" }
+
+customfieldsgroup_makedefault:
+ path: /{_locale}/admin/customfieldsgroup/make_default
+ defaults: { _controller: "ChillCustomFieldsBundle:CustomFieldsGroup:makeDefault" }
customfieldsgroup_new:
path: /{_locale}/admin/customfieldsgroup/new
diff --git a/Resources/config/services.yml b/Resources/config/services.yml
index af7b05b91..1f073c09b 100644
--- a/Resources/config/services.yml
+++ b/Resources/config/services.yml
@@ -11,6 +11,7 @@ services:
class: Chill\CustomFieldsBundle\Form\CustomFieldType
arguments:
- "@chill.custom_field.provider"
+ - "@doctrine.orm.entity_manager"
tags:
- { name: 'form.type', alias: 'custom_field_choice' }
diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml
index 78b57984c..77c13fd1c 100644
--- a/Resources/translations/messages.fr.yml
+++ b/Resources/translations/messages.fr.yml
@@ -1,3 +1,77 @@
'Not available in your language': 'Traduction pas disponible dans votre langue'
'Other value': 'Autre valeur'
'None': 'Pas spécifié'
+
+#customfieldsgroup administration
+CustomFieldsGroup list: Groupes de champs personnalisés
+CustomFieldsGroup creation: Nouveau groupe de champs personnalisés
+Entity: Entité
+"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"
+Make default: Rendre groupe par défaut
+Create a new group: Créer un nouveau groupe
+CustomFieldsGroup details: Détail du groupe de champs personnalisés
+Fields associated with this group: Champs associés à ce groupe
+Any field is currently associated with this group: Aucun champ n'est associé à ce groupe actuellement
+Create a new field: Créer un champ personnalisé
+Add a new field: Ajouter un champ personnalisé
+ordering: ordre
+label_field: label du champ
+active: actif
+No value defined for this option: Pas de valeur pour cette option
+CustomFieldsGroup edit: Edition d'un groupe de champs personnalisé
+type: type
+The custom fields group has been created: Le groupe de champs personnalisés a été créé
+The custom fields group has been updated: Le groupe de champs personnalisés a été mis à jour
+The custom fields group form contains errors: Le formulaire contient des erreurs
+The default custom fields group has been changed: Le groupe par défaut a été changé
+
+
+#menu entries
+Custom fields configuration: Champs personnalisés
+CustomFields List: Liste des champs personnalisés
+CustomFields Groups: Groupe de champs personnalisés
+
+#customfield administration
+CustomField edit: Modification d'un champ personnalisé
+CustomField creation: Nouveau champ personnalisé
+General informations: Informations générales
+Options: Options
+Custom fields group: Groupe de champ personnalisé
+Ordering: Ordre d'apparition
+Back to the group: Retour au groupe de champs personnalisé
+Slug: Identifiant textuel
+The custom field has been created: Le champ personnalisé est créé
+The custom field form contains errors: Le formulaire contient des erreurs
+The custom field has been updated: Le champ personnalisé a été mis à jour
+
+#custom field name
+choice: choix
+title: titre
+text: texte
+text field: champ texte
+
+#custom field choice
+Multiplicity: Multiplicité
+Multiple: Multiple
+Unique: Un seul choix possible
+Choice display: Affichage des choix
+Expanded: Choix étendus (boutons radio)
+Non expanded: Choix rassemblés
+Allow other: Autoriser une autre valeur
+No: Non
+Yes: Oui
+Other value label (empty if use by default): Label du champ "autre valeur"
+Choices: Choix
+Add an element: Ajouter un élément
+
+#custom field text
+Max length: Longueur maximum
+Box appearance: Apparence du champ
+Multiple boxes on the line: Plusieurs champs sur la ligne
+One box on the line: Un seul champ sur la ligne
+
+#custom field title
+Title level: Niveau de titre
+Main title: Titre principal
+Subtitle: Sous-titre
diff --git a/Resources/views/CustomField/edit.html.twig b/Resources/views/CustomField/edit.html.twig
index bcc2e5d88..08fbed2ce 100644
--- a/Resources/views/CustomField/edit.html.twig
+++ b/Resources/views/CustomField/edit.html.twig
@@ -16,17 +16,33 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
-{% block admin_content %}
-
CustomField edit
+{% block title %}{{ 'CustomField edit'|trans }}{% endblock title %}
- {{ form(edit_form) }}
+{% block admin_content %}
+ {{ 'CustomField edit'|trans }}
+
+ {{ 'General informations'|trans }}
+ {{ form_start(edit_form) }}
+ {{ form_row(edit_form.name) }}
+ {{ form_row(edit_form.active) }}
+ {% if edit_form.customFieldsGroup is defined %}
+ {{ form_row(edit_form.customFieldsGroup) }}
+ {% endif %}
+ {{ form_row(edit_form.ordering) }}
+ {% if edit_form.options is not empty %}
+ {{ 'Options'|trans }}
+ {% for option in edit_form.options %}
+ {{ form_row(option) }}
+ {% endfor %}
+ {% endif %}
+ {{ form_row(edit_form.submit, {'attr': { 'class': 'sc-button btn-update' } } ) }}
+ {{ form_end(edit_form) }}
{% endblock %}
diff --git a/Resources/views/CustomField/index.html.twig b/Resources/views/CustomField/index.html.twig
deleted file mode 100644
index 36c5f1243..000000000
--- a/Resources/views/CustomField/index.html.twig
+++ /dev/null
@@ -1,66 +0,0 @@
-{#
- * Copyright (C) 2014, Champs Libres Cooperative SCRLFS,
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
-#}
-{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
-
-{% block admin_content %}
- CustomField list
-
-
-
-
- Id
- Label
- Type
- Active
- Actions
-
-
-
- {% for entity in entities %}
-
- {{ entity.id }}
- {{ entity.name(app.request.locale) }}
- {{ entity.type }}
- {{ entity.active }}
-
-
-
-
- {% endfor %}
-
-
-
-
-
- {{ form_start(form) }}
-
- {{ form_row(form) }}
-
- Create a new entry
-
-
- {{ form_end(form) }}
-
-
- {% endblock %}
diff --git a/Resources/views/CustomField/new.html.twig b/Resources/views/CustomField/new.html.twig
index a94f16b3b..783cbb1d6 100644
--- a/Resources/views/CustomField/new.html.twig
+++ b/Resources/views/CustomField/new.html.twig
@@ -16,15 +16,40 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
-{% block admin_content %}
- CustomField creation
+{% block title %}{{ 'CustomField creation'|trans }}{% endblock title %}
- {{ form(form) }}
-
+{% block admin_content %}
+ {{ 'CustomField creation'|trans }}
+
+ {{ 'General informations'|trans }}
+ {{ form_start(form) }}
+ {{ form_row(form.name) }}
+ {{ form_row(form.active) }}
+ {{ form_row(form.slug) }}
+ {% if form.customFieldsGroup is defined %}
+ {{ form_row(form.customFieldsGroup) }}
+ {% endif %}
+ {{ form_row(form.ordering) }}
+ {% if form.options is not empty %}
+ {{ 'Options'|trans }}
+ {% for option in form.options %}
+ {{ form_row(option) }}
+ {% endfor %}
+ {% endif %}
+ {{ form_row(form.submit, {'attr': { 'class': 'sc-button btn-create' } } ) }}
+ {{ form_end(form) }}
+
+
{% endblock %}
diff --git a/Resources/views/CustomFieldsDefaultGroup/list.html.twig b/Resources/views/CustomFieldsDefaultGroup/list.html.twig
deleted file mode 100644
index 036bc04d5..000000000
--- a/Resources/views/CustomFieldsDefaultGroup/list.html.twig
+++ /dev/null
@@ -1,46 +0,0 @@
-{#
- * Copyright (C) 2014, Champs Libres Cooperative SCRLFS,
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
-#}
-{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
-
-{% block admin_content %}
- CustomFieldsDefaultGroup list
-
-
-
-
- Entity
- CustomFieldGroup
-
-
-
- {% for defaultGroup in defaultGroups %}
-
- {{ defaultGroup.entity }}
- {{ defaultGroup.customFieldsGroup.name['fr'] }}
-
- {% endfor %}
-
-
-
- {{ form_start(form) }}
- {{ form_row(form.cFGroup) }}
-
-
- set as Default
-
- {{ form_end(form) }}
-{% endblock %}
diff --git a/Resources/views/CustomFieldsGroup/edit.html.twig b/Resources/views/CustomFieldsGroup/edit.html.twig
index 3197f9d90..823f492c2 100644
--- a/Resources/views/CustomFieldsGroup/edit.html.twig
+++ b/Resources/views/CustomFieldsGroup/edit.html.twig
@@ -16,17 +16,30 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
-{% block admin_content %}
- CustomFieldsGroup edit
+{% block title %}{{ 'CustomFieldsGroup edit'|trans }}{% endblock %}
- {{ form(edit_form) }}
+{% block admin_content %}
+ {{ 'CustomFieldsGroup edit'|trans }}
+
+ {{ form_start(edit_form) }}
+ {{ form_row(edit_form.name) }}
+ {{ form_row(edit_form.entity) }}
+ {% if edit_form.options is defined %}
+ {{ form_row(edit_form.options) }}
+ {% endif %}
+ {{ form_row(edit_form.submit, { 'attr': { 'class': 'sc-button bt-edit' } } ) }}
+ {{ form_end(edit_form) }}
{% endblock %}
diff --git a/Resources/views/CustomFieldsGroup/index.html.twig b/Resources/views/CustomFieldsGroup/index.html.twig
index 4f751490d..9a722b180 100644
--- a/Resources/views/CustomFieldsGroup/index.html.twig
+++ b/Resources/views/CustomFieldsGroup/index.html.twig
@@ -16,31 +16,41 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
+{% block title %}{{ 'CustomFieldsGroup list'|trans }}{% endblock %}
+
{% block admin_content %}
- CustomFieldsGroup list
+ {{ 'CustomFieldsGroup list'|trans }}
- Id
- Name
- Entity
- Actions
+ {{ 'Name'|trans }}
+ {{ 'Entity'|trans }}
+ {{ 'Is default ?'|trans }}
+ {{ 'Actions'|trans }}
{% for entity in entities %}
- {{ entity.id }}
- {{ entity.name['fr'] }}
- {{ entity.entity }}
+ {{ entity.name|localize_translatable_string }}
+ {{ entity.entity|trans }}
+
+ {%- if entity.id in default_groups -%}
+
+ {%- else -%}
+ {{ form_start(make_default_forms[entity.id]) }}
+ {{ form_widget(make_default_forms[entity.id].submit, { 'attr' : { 'class' : 'sc-button bt-action' } } ) }}
+ {{ form_end(make_default_forms[entity.id]) }}
+ {%- endif -%}
+
@@ -49,11 +59,9 @@
-
+
+
+ {{ 'Create a new group'|trans }}
+
+
{% endblock %}
diff --git a/Resources/views/CustomFieldsGroup/new.html.twig b/Resources/views/CustomFieldsGroup/new.html.twig
index 19ab309f6..3c0692773 100644
--- a/Resources/views/CustomFieldsGroup/new.html.twig
+++ b/Resources/views/CustomFieldsGroup/new.html.twig
@@ -17,15 +17,16 @@
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
{% block admin_content %}
- CustomFieldsGroup creation
+ {{ 'CustomFieldsGroup creation'|trans }}
- {{ form(form) }}
-
-
+
+ {{ form_end(form) }}
{% endblock %}
diff --git a/Resources/views/CustomFieldsGroup/show.html.twig b/Resources/views/CustomFieldsGroup/show.html.twig
index 84a0141d2..d2f9d4e33 100644
--- a/Resources/views/CustomFieldsGroup/show.html.twig
+++ b/Resources/views/CustomFieldsGroup/show.html.twig
@@ -16,37 +16,101 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
+{% block title %}{{ 'CustomFieldsGroup details'|trans }}{% endblock %}
+
{% block admin_content %}
- CustomFieldsGroup
+ {{ 'CustomFieldsGroup details'|trans }}
- Id
- {{ entity.id }}
+ {{ 'Name'|trans }}
+ {{ entity.getName|localize_translatable_string }}
- Name
- {{ entity.getName(app.request.locale) }}
+ {{ 'Entity'|trans }}
+ {{ entity.entity|trans }}
+ {%- for key in options -%}
- Entity
- {{ entity.entity }}
+ {{ key ~ '_label'|trans }}
+
+ {%- if entity.options[key] is not defined -%}
+ {{ 'No value defined for this option'|trans }}
+ {%- elseif entity.options[key] is iterable -%}
+ {{ entity.options[key]|join(', ') }}
+ {% else %}
+ {{ entity.options[key] }}
+ {%- endif -%}
+
+ {%- else -%}
+
+ {%- endfor -%}
-
+
+
+ {{ 'Fields associated with this group'|trans }}
+
+ {%- if entity.customFields|length > 0 -%}
+
+
+
+ {{ 'ordering'|trans|capitalize }}
+ {{ 'label_field'|trans|capitalize }}
+ {{ 'type'|trans|capitalize }}
+ {{ 'active'|trans|capitalize }}
+
+
+
+
+ {%- for field in entity.customFields -%}
+
+ {{ field.ordering }}
+ {{ field.name|localize_translatable_string }}
+ {{ field.type|trans }}
+
+ {%- if field.active -%}
+
+ {%- else -%}
+
+ {%- endif -%}
+
+
+ {{ 'edit'|trans|capitalize }}
+
+
+ {%- endfor -%}
+
+
+ {{ form_start(create_field_form) }}
+
+ {{ form_widget(create_field_form.type) }}
+
+ {{ form_widget(create_field_form.submit, { 'attr': { 'class': 'sc-button bt-create' }, 'label': 'Add a new field' } ) }}
+ {{ form_end(create_field_form) }}
+ {%- else -%}
+
+ {{ 'Any field is currently associated with this group'|trans }}
+
+ {{ form_start(create_field_form) }}
+
+ {{ form_widget(create_field_form.type) }}
+
+ {{ form_widget(create_field_form.submit, { 'attr': { 'class': 'sc-button bt-create' }, 'label': 'Create a new field' } ) }}
+ {{ form_end(create_field_form) }}
+ {%- endif -%}
{% endblock %}
diff --git a/Resources/views/Form/fields.html.twig b/Resources/views/Form/fields.html.twig
index 76ec0cb5c..04febae3c 100644
--- a/Resources/views/Form/fields.html.twig
+++ b/Resources/views/Form/fields.html.twig
@@ -32,10 +32,24 @@
{% endblock cf_choices_list_widget %}
-{# render the possibility to add different elements in a choice list #}
-{% block cf_choices_widget %}
-
- {{ form(form) }}
+{# CFChoice : render the different elements in a choice list #}
+{% block cf_choices_row %}
+ {{ 'Choices'|trans }}
+
+
+
{# we use javascrit to add an additional element. All functions are personnalized with the id ( = form.vars.id) #}
-{% endblock cf_choices_widget %}
+{% endblock cf_choices_row %}
{% block choice_with_other_widget %}
diff --git a/Tests/Config/ConfigCustomizablesEntitiesTest.php b/Tests/Config/ConfigCustomizablesEntitiesTest.php
index deb9585e2..df66ab56c 100644
--- a/Tests/Config/ConfigCustomizablesEntitiesTest.php
+++ b/Tests/Config/ConfigCustomizablesEntitiesTest.php
@@ -43,7 +43,7 @@ class ConfigCustomizablesEntitiesTest extends KernelTestCase
->getParameter('chill_custom_fields.customizables_entities');
$this->assertInternalType('array', $customizableEntities);
- $this->assertCount(0, $customizableEntities);
+ $this->assertCount(1, $customizableEntities);
}
/**
@@ -59,7 +59,7 @@ class ConfigCustomizablesEntitiesTest extends KernelTestCase
->getParameter('chill_custom_fields.customizables_entities');
$this->assertInternalType('array', $customizableEntities);
- $this->assertCount(1, $customizableEntities);
+ $this->assertCount(2, $customizableEntities);
foreach($customizableEntities as $key => $config) {
$this->assertInternalType('array', $config);
diff --git a/Tests/Controller/CustomFieldsGroupControllerTest.php b/Tests/Controller/CustomFieldsGroupControllerTest.php
new file mode 100644
index 000000000..b6bc3bbee
--- /dev/null
+++ b/Tests/Controller/CustomFieldsGroupControllerTest.php
@@ -0,0 +1,67 @@
+ 'test_customizable_entities_test_not_empty_config'));
+ // Create a new client to browse the application
+ $client = static::createClient(array(), array(
+ 'PHP_AUTH_USER' => 'admin',
+ 'PHP_AUTH_PW' => 'olala',
+ ));
+
+ //create the entity
+ $this->createCustomFieldsGroup($client);
+
+ // Edit the entity
+ $this->editCustomFieldsGroup($client);
+ }
+
+ private function createCustomFieldsGroup(Client &$client)
+ {
+ // Create a new entry in the database
+ $crawler = $client->request('GET', '/fr/admin/customfieldsgroup/');
+ $this->assertEquals(200, $client->getResponse()->getStatusCode(),
+ "Unexpected HTTP status code for GET /customfieldsgroup/");
+
+ $crawler = $client->click($crawler->selectLink('Créer un nouveau groupe')->link());
+
+ // Fill in the form and submit it
+ $form = $crawler->selectButton('Créer')->form(array(
+ 'custom_fields_group[name][fr]' => 'Test',
+ 'custom_fields_group[entity]' => 'Chill\PersonBundle\Entity\Person'
+ ));
+
+ $crawler = $client->submit($form);
+
+ $crawler = $client->followRedirect();
+
+ // Check data in the show view
+ $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(),
+ 'Missing element td:contains("Test")');
+ }
+
+ private function editCustomFieldsGroup(Client $client)
+ {
+ $crawler = $client->request('GET', '/fr/admin/customfieldsgroup/');
+ $crawler = $client->click($crawler->selectLink('modifier')->link());
+
+ $form = $crawler->selectButton('Update')->form(array(
+ 'custom_fields_group[name][fr]' => 'Foo',
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check the element contains an attribute with value equals "Foo"
+ $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(),
+ 'Missing element [value="Foo"]');
+ }
+}
diff --git a/Tests/Controller/CustomFieldsGroupControllerTest_TODO.php b/Tests/Controller/CustomFieldsGroupControllerTest_TODO.php
deleted file mode 100644
index afa7bad25..000000000
--- a/Tests/Controller/CustomFieldsGroupControllerTest_TODO.php
+++ /dev/null
@@ -1,55 +0,0 @@
-request('GET', '/customfieldsgroup/');
- $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /customfieldsgroup/");
- $crawler = $client->click($crawler->selectLink('Create a new entry')->link());
-
- // Fill in the form and submit it
- $form = $crawler->selectButton('Create')->form(array(
- 'cl_customfieldsbundle_customfieldsgroup[field_name]' => 'Test',
- // ... other fields to fill
- ));
-
- $client->submit($form);
- $crawler = $client->followRedirect();
-
- // Check data in the show view
- $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
-
- // Edit the entity
- $crawler = $client->click($crawler->selectLink('Edit')->link());
-
- $form = $crawler->selectButton('Update')->form(array(
- 'cl_customfieldsbundle_customfieldsgroup[field_name]' => 'Foo',
- // ... other fields to fill
- ));
-
- $client->submit($form);
- $crawler = $client->followRedirect();
-
- // Check the element contains an attribute with value equals "Foo"
- $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
-
- // Delete the entity
- $client->submit($crawler->selectButton('Delete')->form());
- $crawler = $client->followRedirect();
-
- // Check the entity has been delete on the list
- $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
- }
-
- */
-}
diff --git a/Tests/CustomFields/CustomFieldsTextTest.php b/Tests/CustomFields/CustomFieldsTextTest.php
index 205dc7dfe..00130df80 100644
--- a/Tests/CustomFields/CustomFieldsTextTest.php
+++ b/Tests/CustomFields/CustomFieldsTextTest.php
@@ -100,4 +100,5 @@ class CustomFieldsTextTest extends WebTestCase
$form = $crawler->selectButton('custom_field_choice_submit')->form();
$this->assertTrue($form->has('custom_field_choice[options][maxLength]'));
}
+
}
diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Tests/Fixtures/App/app/AppKernel.php
index 59ec46bfa..d2e57ab94 100644
--- a/Tests/Fixtures/App/app/AppKernel.php
+++ b/Tests/Fixtures/App/app/AppKernel.php
@@ -17,7 +17,8 @@ class AppKernel extends Kernel
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Chill\MainBundle\ChillMainBundle,
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
- new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle()
+ new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
+ new Chill\PersonBundle\ChillPersonBundle(),
#add here all the required bundle (some bundle are not required)
);
}
diff --git a/composer.json b/composer.json
index af1c0c6b4..32c01e7f5 100644
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,7 @@
],
"require": {
"php": "~5.5",
- "symfony/symfony": "~2.7",
+ "symfony/symfony": "2.7.*",
"doctrine/orm": "~2.4",
"doctrine/dbal" : "~2.5",
"doctrine/common": "~2.4",
@@ -34,7 +34,8 @@
"chill-project/main": "dev-master"
},
"require-dev": {
- "doctrine/doctrine-fixtures-bundle": "~2.2@dev"
+ "doctrine/doctrine-fixtures-bundle": "~2.2@dev",
+ "chill-project/person": "dev-master@dev"
},
"scripts": {
"post-install-cmd": [
@@ -54,6 +55,9 @@
},
"extra": {
"symfony-app-dir": "Tests/Fixtures/App/app",
- "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations"
+ "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations",
+ "branch-alias": {
+ "dev-master": "fix_admin_interface-dev"
+ }
}
}