security = $security; $this->params = $params; } 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' => 'name.label', 'attr' => ['placeholder' => 'part.name.placeholder'], 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]) ->add('parent', EntityType::class, ['class' => get_class($entity), 'choice_label' => 'full_path', 'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false, 'label' => 'parent.label', 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]) ->add('not_selectable', CheckboxType::class, ['required' => false, 'label' => 'not_selectable.label', 'help' => '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' => 'comment.label', 'attr' => ['rows' => 4], 'help' => '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 ? 'entity.create' : '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 } }