title: Zf2 - I am not able to define the form as shared one using its name as well as alias
body: <p>I am working on ZendFramework 2. I have a form which I want to be used as a shared instance. But the <code>shared</code> key only accepts the actual class rather then the name allocated to it. Sharing some of the code snippet for better understanding of my problem:</p>
  
  <p>SampleForm.php</p>
  
  <pre><code>namespace MyProject\Form;
  
  use Zend\Form\Form;
  
  class Sampleform extends Form
  {
      public function __construct()
      {
          parent::__construct('sampelname');
      }
  
      /**
       * Initialize the form elements
       */
      public function init()
      {
          $this-&gt;add(
              [
                  'type' =&gt; 'Text',
                  'name' =&gt; 'name',
                  'options' =&gt; [
                      'label' =&gt; 'Enter your name',
                  ]
              ]
          );
      }
  }
  </code></pre>
  
  <p>Defining the <code>SampleForm</code> in <code>Module.php</code>:</p>
  
  <pre><code>namespace MyProject;
  
  use Zend\ModuleManager\Feature\ConfigProviderInterface;
  use Zend\ModuleManager\Feature\FormElementProviderInterface;
  use MyProject\Form\SampleForm;
  
  class Module implements ConfigProviderInterface, FormElementProviderInterface
  {
      /**
       * {@inheritDoc}
       */
      public function getConfig()
      {
          return include __DIR__ . '/config/module.config.php';
      }
  
      /**
       * {@inheritdoc}
       */
      public function getFormElementConfig()
      {
          return [
              'invokables' =&gt; [
                  'MyProject\Form\SharedSampleForm' =&gt; SampleForm::class,
              ],
              'aliases' =&gt; [
                  'sharedSampleForm' =&gt; 'MyProject\Form\SharedSampleForm'
              ],
              'shared' =&gt; [
                  'MyProject\Form\SharedSampleForm' =&gt; true
              ]
          ];
      }
  }
  </code></pre>
  
  <p>It throws me the error like:
  <code>Zend\ServiceManager\Exception\ServiceNotFoundException: Zend\Form\FormElementManager\FormElementManagerV2Polyfill::setShared: A service by the name "MyProject\Form\SharedSampleForm" was not found and could not be marked as shared</code></p>
  
  <p>But it works as expected when I define my <code>getFormElementConfig</code> in <code>Module.php</code> as follows:</p>
  
  <pre><code>public function getFormElementConfig()
  {
      return [
          'invokables' =&gt; [
              'MyProject\Form\SharedSampleForm' =&gt; SampleForm::class,
          ],
          'aliases' =&gt; [
              'sharedSampleForm' =&gt; 'MyProject\Form\SharedSampleForm'
          ],
          'shared' =&gt; [
              SampleForm::class =&gt; true
          ]
      ];
  }
  </code></pre>
  
  <p>i.e. In the <code>shared</code> key I provide the reference to the actual Form class name.</p>
  
  <p>If the same definitions are defined under <code>getServiceConfig()</code> then it works as expected without throwing any such error.</p>
  
  <p>Can some one please suggest/help me out how can I be able to use the service name in the <code>shared</code> for forms then providing the actual class reference?</p>