title: How to override sonata admin controller to provide fields of another object
body: <p>I'm quite new with Symfony and particularly with Sonata Admin. In my project, I have an entity Project, with a OneToMany relation with a CommunicationDetails entity. This CommunicationDetails entity is linked to a DataSource entity with a ManyToOne relation.</p>
  
  <p>A DataSource is a third-application I have to call to get information about a project. A project can be linked with many data sources. Each communication (project-datasource) needs a project_datasource_id, which is the project's ID in the 3rd party app.</p>
  
  <pre><code>/**
  * @ORM\Table(name="project")
  * @ORM\Entity
  */
  class Project {
      ...
  
      /**
       * @ORM\OneToMany(targetEntity="CommunicationDetails", mappedBy="project", cascade={"persist"}, indexBy="project")
       */
      private $details;
  }
  
  
  
  /**
  * @ORM\Table(name="communication_details")
  * @ORM\Entity;
  */
  class CommunicationDetails {
  
  ...
  
  /**
   * @ORM\ManyToOne(targetEntity="Project", inversedBy="details")
   */
  private $project;
  
  }
  
  
  
  /**
   * @ORM\Table(name="datasource")
   * @ORM\Entity
   */
  class DataSource{
  
  ...
  
  /**
   * @ORM\OneToMany(targetEntity="CommunicationDetails", mappedBy="dataSource", cascade={"persist"}, indexBy="dataSource")
   */
  private $details;
  </code></pre>
  
  <p>I've no problem to manage this behavior with Sonata but I would like to improve the creation process a little bit.
  I would like to provide fields of the CommunicatonDetails entity when I'm creating a project. In fact, I'm looking for something like this (even if I know that I can't do it this way) : </p>
  
  <pre><code>$mapper
  -&gt;with('General', ['class' =&gt; 'col-md-4'])
      -&gt;add('name', TextType::class)
      -&gt;add('description', TextareaType::class)
      // Here, I'd like to provide fields of the CommunicationDetails entity to create these objects in the same time
      -&gt;add('details.project_datasource_id', TextType::class)
      -&gt;add('details.basePath', TextType::class)
  -&gt;end();
  </code></pre>
  
  <p>I read a lot of articles concerning Sonata and its CRUDController, and I think I have to implement it this way. However, I didn't find how to do it. I had a look to the basic sonata template, which I'll have to override too, but every form element displayed are linked with my model, so I've no idea how I could add my own fields.
  If someone has some link to give, or any idea, I would be really grateful !</p>
  
  <p>PS : I did my best, sorry for my english errors.</p>