title: Zend framework 2: Form bind not setting the values extracted from database
body: <p>I want to create a form with Zend Framework 2 for my application and I have everything in place and the form is getting displayed but my issue is I am not able to bind the initial form values that come from the database</p>
  
  <pre><code>$myUserDetails = &lt;details of my user coming from DB&gt;;
  $form = $form-&gt;bind($myUserDetails); //This should set the values for the form to display but it doesnt
  </code></pre>
  
  <p>My display logic is simple as shown below </p>
  
  <pre><code>$form = $this-&gt;form;
  $form-&gt;setAttribute('action', 
  $this-&gt;url('&lt;routename&gt;',array('action'=&gt;'&lt;actionname&gt;')));
  $form-&gt;prepare();
  echo $this-&gt;form()-&gt;openTag($form) . PHP_EOL;
  echo $this-&gt;formRow($form-&gt;get('email_id')) . PHP_EOL;
  echo $this-&gt;formRow($form-&gt;get('dob')) . PHP_EOL;
  echo $this-&gt;formRow($form-&gt;get('gender')) . PHP_EOL;
  echo $this-&gt;formRow($form-&gt;get('user_page_name')) . PHP_EOL;
  echo $this-&gt;formInput($form-&gt;get('submit')) . PHP_EOL;
  echo $this-&gt;form()-&gt;closeTag($form) . PHP_EOL;
  </code></pre>
  
  <p>Now I tried to set the data from my object that I bind to the form in my controller action</p>
  
  <pre><code>$myUserDetails = &lt;details of my user coming from DB&gt;;
  $form = $form-&gt;bind($myUserDetails);
  $data = $myUserDetails-&gt;getArrayCopy();
  $form-&gt;setData($data['data']);
  </code></pre>
  
  <p>This seems to work somehow and is displaying my values in the view. So i just want to know what have I done wrong in my first approach? Thanks in advance :)</p>