title: How to get child object in embedded Admin class in Sonata Admin?
body: <p>I'm trying to get and manipulate the actual object related to a ImageAdmin class in SonataAdmin (using Symfony 2.3). This works fine when the ImageAdmin class is the only one being used. But when ImageAdmin is embedded in another Admin it goes horribly wrong.</p>
  
  <p>Here's what works when you don't have embedded Admins:</p>
  
  <pre><code>class ImageAdmin extends Admin {
      protected $baseRoutePattern = 'image';
  
      protected function configureFormFields(FormMapper $formMapper) {
          $subject = $this-&gt;getSubject();
      }
  }
  </code></pre>
  
  <p>But when you embed ImageAdmin in ParentAdmin using this:</p>
  
  <pre><code>class PageAdmin extends Admin {
      protected function configureFormFields(FormMapper $formMapper) {
          $formMapper-&gt;add('image1', 'sonata_type_admin');
      }
  }
  </code></pre>
  
  <p>Then when you're editing a Parent item with id 10 and call getSubject() in ImageAdmin you get the <strong><em>Image</em></strong> with id 10!</p>
  
  <p>In other words getSubject() extracts the id from the URL then calls <code>$this-&gt;getModelManager()-&gt;find($this-&gt;getClass(), $id);</code>, which cross-references the Parent id and the Image id. Oops!</p>
  
  <hr>
  
  <p>So... what I want to do is be able to get hold of the actual object that is being rendered/edited in the current ImageAdmin instance, whether it's being edited directly or via an embedded form, and then be able to do things with it.</p>
  
  <p>Maybe getSubject() is the wrong tree to be barking up, but I note that <code>$this-&gt;getCurrentChild()</code> returns false when called from ImageAdmin::configureFormFields(), even when that ImageAdmin is embedded using the sonata_type_admin field type. I'm quite confused...</p>
  
  <p>Anyway, I hope it is possible to get hold of the object in some obvious way that I've overlooked and somebody here can help enlighten me!</p>