ZF2 add elemets to form on the fly from database
<p>In ZF2, I get the form from the controller factory like this:</p>

<pre><code>class SomeControllerFactory implements FactoryInterface
{
    public function CreateService(SeviceLocatorInterface $serviceLocator)
    {
        $realServiceLocator   = $serviceLocator-&gt;getServiceLocator();
        // other things from service manager
        $registrationForm = $realServiceLocator-&gt;get('FormElementManager')
            -&gt;get('Path\To\My\Form\RegistrationForm');
    }
    return new SomeController(
        // controller dependencies, including $registrationForm
    );
}
</code></pre>

<p>In the <code>RegistrationForm</code>, I have <code>MultiCheckBox</code>: </p>

<pre><code>    $this-&gt;add([
        'type' =&gt; 'Zend\Form\Element\MultiCheckBox',
        'name' =&gt; 'partyRoleIds',
        'options' =&gt; [
            'label' =&gt; 'Отношение',
            'value_options' =&gt; [
                [
                    'value' =&gt; '1',
                    'label' =&gt; 'client',
                ],
                [
                    'value' =&gt; '2',
                    'label' =&gt; 'prospect'],
                [
                    'value' =&gt; '6',
                    'label' =&gt; 'contractor',
                ],
            ],
        ],
    ]);
</code></pre>

<p>I want to populate <code>value_options</code> from a db query that returns an array like <code>[1 =&gt; 'client', 2 =&gt; 'prospect'...]</code>. Populating is not an problem, but I don't know how to pass this array as a dependency into the <code>RegistrationForm</code> because in the call <code>$registrationForm = $realServiceLocator-&gt;get('FormElementManager')-&gt;get('Path\To\My\Form\RegistrationForm');</code>, I don't have any place to add the dependency.</p>

<p>How could I do this?</p>

<p>PS: rewritten the question, please forgive my initial brevity. </p>