/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { parent::configureFormFields($formMapper); $formMapper->with('form.group_general')->add('title', 'text', array('required' => false))->end()->with('Items')->add('children', 'sonata_type_collection', array(), array('edit' => 'inline', 'inline' => 'table', 'admin_code' => $this->embeddedAdminCode, 'sortable' => 'position'))->end(); if (null === $this->getParentFieldDescription()) { $formMapper->with('form.group_general')->add('parentDocument', 'doctrine_phpcr_odm_tree', array('root_node' => $this->getRootPath(), 'choice_list' => array(), 'select_root_node' => true))->add('name', 'text')->end(); } }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { parent::configureFormFields($formMapper); // image is only required when creating a new item // TODO: sonata is not using one admin instance per object, so this doesn't really work - https://github.com/symfony-cmf/BlockBundle/issues/151 $imageRequired = $this->getSubject() && $this->getSubject()->getParentDocument() ? false : true; if (null === $this->getParentFieldDescription()) { $formMapper->with('form.group_general')->add('parentDocument', TreeModelType::class, array('root_node' => $this->getRootPath(), 'choice_list' => array(), 'select_root_node' => true))->add('name', TextType::class)->end(); } $formMapper->with('form.group_general')->add('label', TextType::class, array('required' => false))->add('linkUrl', TextType::class, array('required' => false))->add('filter', TextType::class, array('required' => false))->add('image', ImageType::class, array('required' => $imageRequired))->add('position', HiddenType::class, array('mapped' => false))->end(); }