INVALID MODE : s5a869f19a6c57_equivalents - type : sonata_type_collection - mapping :

社会主义新天地 提交于 2021-02-10 20:22:52

问题


I am building a new feature onto a Symfony 2.8 application using a few Sonata bundles.

My Page.php entity definition includes the following mapping:

/**
 * @var ArrayCollection
 *
 * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Equivalent", cascade={"all"})
 * @ORM\JoinTable(name="page_equivalent",
 *          joinColumns={@ORM\JoinColumn(name="page_id", referencedColumnName="id")},
 *          inverseJoinColumns={@ORM\JoinColumn(name="equivalent_id", referencedColumnName="id", unique=true)}
 *     )
 */
private $equivalents;

... and my PageAdmin.php file's configureFormFields() function contains the following:

            ->add('synonyms', CollectionType::class, array('entry_type' => TextType::class, 'allow_add' => true, 'allow_delete' => true))
            ->add('equivalents', 'sonata_type_collection', array(
                'label' => "Equivalents",
                'cascade_validation' => true,
                'required' => false,
            ), array(
                'edit' => 'inline',
                'inline' => 'table',
                'targetEntity' => 'AppBundle\Entity\Equivalent',
                'admin_code' => 'app.admin.equivalent',
            ))

... which yields the message

INVALID MODE : s5a869f19a6c57_equivalents - type : sonata_type_collection - mapping :

I have tried setting by_reference to both true and false, and neither setting seemed to change anything. I have also run doctrine:schema:validate and spotted no problems. I have also verified that I am able to add and edit Equivalent objects in my CMS.

What can I do to fix this?


回答1:


It turns out that this problem involved an ORM mapping that was not getting read.

(The piece of logic where the complaint lived was checking for one of several ORM mapping types, then complaining if none of those types was found.)

Running app/console doctrine:cache:clear-metadata and then re-running my doctrine:schema:update --force command was enough to get my application to recognize the many-to-many relationship that I had been trying to put in place. This got rid of the cranky message.



来源:https://stackoverflow.com/questions/48823406/invalid-mode-s5a869f19a6c57-equivalents-type-sonata-type-collection-mapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!