Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7793941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:38:46+00:00 2026-06-01T22:38:46+00:00

Here is my TagAdmin class protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add(‘name’) ->add(‘description’) ->add(‘slug’,’text’,array(

  • 0

Here is my TagAdmin class

protected function configureFormFields(FormMapper $formMapper) 
    { 
        $formMapper 
            ->add('name') 
            ->add('description') 
            ->add('slug','text',array( 
                'read_only' => true, 
            )) 
            ->add('categories', 'sonata_type_model', array('expanded' 
=> true, 'multiple' => true)); 
    } 

There is a manyToMany mapping between Categories and Tags.

I recently upgraded to Sonata Admin version 2.0.

I am sure it was working earlier, but now when I add new Categories to
a Tag, I get a success flash message, but the change is not
reflected.

The only other change I had made was to integrate the Chosen JQuery
plugin for handling checkboxes. I have tried with removing that too,
but it functions just the same.

What could be going wrong?

Here is the Tag class.

class Tag 
{ 
    /** 
     * @var integer $id 
     * 
     * @ORM\Column(name="id", type="integer") 
     * @ORM\Id 
     * @ORM\GeneratedValue(strategy="AUTO") 
     */ 
    private $id; 
    /** 
     * @var string $name 
     * 
     * @Gedmo\Sluggable(slugField="slug") 
     * @ORM\Column(name="name", type="string", length=255) 
     * @Gedmo\Translatable 
     */ 
    private $name; 
    /** 
     * @var text $description 
     * 
     * @ORM\Column(name="description", type="text") 
     * @Gedmo\Translatable 
     */ 
    private $description; 
    /** 
     * @ORM\ManyToMany(targetEntity="Category", mappedBy="tags") 
     */ 
    protected $categories; 
    /** 
     * @var string $slug 
     * @Gedmo\Slug(updatable=false) 
     * @ORM\Column(name="slug", type="string", length=255) 
     */ 
    private $slug; 
    public function __construct() 
    { 
        $this->categories = new \Doctrine\Common\Collections 
\ArrayCollection(); 
    } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:38:48+00:00Added an answer on June 1, 2026 at 10:38 pm

    Sorry, this had nothing to do with Sonata.

    It was a problem with the mapping. The Doctrine2 documentation states:

    The owning side of a relationship determines the updates to the relationship in the database.

    To fully understand this, remember how bidirectional associations are
    maintained in the object world. There are 2 references on each side of
    the association and these 2 references both represent the same
    association but can change independently of one another. Of course, in
    a correct application the semantics of the bidirectional association
    are properly maintained by the application developer (that’s his
    responsibility). Doctrine needs to know which of these two in-memory
    references is the one that should be persisted and which not. This is
    what the owning/inverse concept is mainly used for.

    Changes made only to the inverse side of an association are ignored.
    Make sure to update both sides of a bidirectional association (or at
    least the owning side, from Doctrine’s point of view)

    The owning side of a bidirectional association is the side Doctrine
    “looks at” when determining the state of the association, and
    consequently whether there is anything to do to update the association
    in the database.

    My mapping was defined like this:-

    class Tag
    {
    ...
       /**
         * @ORM\ManyToMany(targetEntity="Category", mappedBy="tags")
         */
        protected $categories;
    ...
    }
    
    class Category
    {
    ...
       /**
         * @ORM\ManyToMany(targetEntity="Tag", inversedBy="categories")
         */
        protected $tags;
    ...
    }
    

    Setting the “inversedBy” to Tag class, solved the issue.
    So the correct implementation is this:

    class Tag
    {
    ...
       /**
         * @ORM\ManyToMany(targetEntity="Category", inversedBy="tags")
         */
        protected $categories;
    ...
    }
    
    class Category
    {
    ...
       /**
         * @ORM\ManyToMany(targetEntity="Tag", mappedBy="categories")
         */
        protected $tags;
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is code: <script type=text/javascript> function doit(){ $('table td').each(function () { if ($(this).text().trim() !=
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
Here's my scenario: <!-- Normal Control --> <div class=required> <label for=address1>Address line 1</label> <input
Here is my HTML. Just a simple form: <form> Username: <input type=text id=username/> <br/>
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
here is what I want to do: Add a CALayer as a sublayer to
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here is a snippet of my xaml: <ComboBox x:Name=cbo1 Width=100 SelectedValue=200> <ComboBoxItem Name=n1>100</ComboBoxItem> <ComboBoxItem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.