fix creation of custom field without cfgroup id

This commit is contained in:
2015-11-30 21:31:58 +01:00
parent 2401270754
commit c9ca7c1e1b
4 changed files with 19 additions and 7 deletions

View File

@@ -76,14 +76,17 @@ class CustomFieldController extends Controller
//add the custom field group if defined in URL
$cfGroupId = $request->query->get('customFieldsGroup', null);
$cfGroup = $this->getDoctrine()->getManager()
->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
->find($cfGroupId);
if (!$cfGroup) {
throw $this->createNotFoundException('CustomFieldsGroup with id '
. $cfGroupId.' is not found !');
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);
}
$entity->setCustomFieldsGroup($cfGroup);
$form = $this->createCreateForm($entity, $request->query->get('type'));