security = $security; $this->params = $params; $this->trans = $trans; } public function buildForm(FormBuilderInterface $builder, array $options) { /** @var StructuralDBElement $entity */ $entity = $options['data']; $is_new = $entity->getID() === null; $builder ->add('name', TextType::class, ['empty_data' => '', 'label' => $this->trans->trans('name.label'), 'attr' => ['placeholder' => $this->trans->trans('part.name.placeholder')], 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]) ->add('parent', StructuralEntityType::class, ['class' => get_class($entity), 'required' => false, 'label' => $this->trans->trans('parent.label'), 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]) ->add('not_selectable', CheckboxType::class, ['required' => false, 'label' => $this->trans->trans('entity.edit.not_selectable'), 'help' => $this->trans->trans('entity.edit.not_selectable.help'), 'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity) ]) ->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '', 'label' => $this->trans->trans('comment.label'), 'attr' => ['rows' => 4], 'help' => $this->trans->trans('bbcode.hint'), 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]); $this->additionalFormElements($builder, $options, $entity); //Buttons $builder->add('save', SubmitType::class, [ 'label' => $is_new ? $this->trans->trans('entity.create') : $this->trans->trans('entity.edit.save'), 'attr' => ['class' => $is_new ? 'btn-success' : ''], 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]) ->add('reset', ResetType::class, ['label' => 'entity.edit.reset', 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]); } protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity) { //Empty for Base } }