Disable parameters fields when user is not allowed to edit data structures.

This commit is contained in:
Jan Böhmer 2020-03-25 15:19:09 +01:00
parent 6841f91ab5
commit e72fc2716b
2 changed files with 5 additions and 4 deletions

View file

@ -156,11 +156,12 @@ class BaseEntityAdminForm extends AbstractType
$builder->add('parameters', CollectionType::class, [
'entry_type' => ParameterType::class,
'allow_add' => true,
'allow_delete' => true,
'allow_add' => $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'allow_delete' => $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'label' => false,
'by_reference' => false,
'prototype_data' => new $options['parameter_class'],
'prototype_data' => new $options['parameter_class'](),
'entry_options' => [
'data_class' => $options['parameter_class'],
],