fix form for new custom group

If the CustomFieldGroup->getEntity is not set, the form for creation throw an error
This commit is contained in:
Julien Fastré 2015-02-24 21:24:42 +01:00
parent 0c2b5f3fb4
commit 0cecb67645

View File

@ -49,11 +49,16 @@ class CustomFieldsGroupType extends AbstractType
))
;
$builder->addEventListener(FormEvents::POST_SET_DATA, function(FormEvent $event)
use ($customizableEntities, $builder){
$builder->addEventListener(FormEvents::POST_SET_DATA,
function(FormEvent $event) use ($customizableEntities, $builder){
$form = $event->getForm();
$group = $event->getData();
//stop the function if entity is not set
if ($group->getEntity() === NULL) {
return;
}
if (count($customizableEntities[$group->getEntity()]['options']) > 0) {
$optionBuilder = $builder
->getFormFactory()