title: ZF2 dont validate element inside a collection
body: <p>i have problems validating a Form with a element of type Collection,</p>
  
  <p>First, I create a "Collection" type element and then I add several text type elements.</p>
  
  <p>the form is rendered correctly, The problem is that the Form is always valid. </p>
  
  <p>How i can validate a collection type element?</p>
  
  <p>Form class:</p>
  
  <pre><code>class TestForm extends Form {
  
  private $inputFilter;
  
  public function __construct($name = null) {
  
      parent::__construct($name);
  
      $this-&gt;add(array(
          'name' =&gt; 'submit',
          'type' =&gt; 'Zend\Form\Element\Submit',
          'options' =&gt; array(
              'label' =&gt; 'Submit',
          ),
          'attributes' =&gt; array(
              'class' =&gt; 'form-control',
              'value' =&gt; 'submit'
          ),
      ));
  
      $docs = array(
          array('name' =&gt; "doc A"),
          array('name' =&gt; "doc B")
      );
  
      // add collection of docs.
  
      $collection = new \Zend\Form\Element\Collection();
      $collection-&gt;setName('docs');
  
      foreach ($docs as $key =&gt; $doc) {
  
          $element = new \Zend\Form\Element\Text($key);
  
          $element-&gt;setOptions(array(
              'label' =&gt; $doc['name'],
          ));
  
          $element-&gt;setAttributes(array(
              'class' =&gt; 'form-control input-sm',
          ));
  
          $collection-&gt;add($element);
      }
  
      $this-&gt;add($collection);
  }
  
  public function getInputFilter() {
  
      $this-&gt;inputFilter = new InputFilter();
  
      $this-&gt;inputFilter-&gt;add(array(
          'name' =&gt; "docs",
          'required' =&gt; true,
          'filters' =&gt; array(
              array('name' =&gt; 'StripTags'),
              array('name' =&gt; 'StringTrim'),
          ),
      ));
  
      return $this-&gt;inputFilter;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Controller class:</p>
  
  <pre><code>class IndexController extends AppController {
  
  public function indexAction() {
  
      $form = new \Application\Model\Form\TestForm();
  
      $request = $this-&gt;getRequest();
  
      if ($request-&gt;isPost()) {
  
          $data = $this-&gt;params()-&gt;fromPost();
          $form-&gt;setData($data);
          $form-&gt;setInputFilter($form-&gt;getInputFilter());
  
          if ($form-&gt;isValid()) {
              pr("is valid");
          } else {
              pr($form-&gt;getMessages());
          }
      }
  
  
      return new ViewModel(array(
          'form' =&gt; $form
      ));
  }
  </code></pre>
  
  <p>View class:</p>
  
  <pre><code>&lt;?php
  $form-&gt;prepare();
  echo $this-&gt;form()-&gt;openTag($form);
  echo $this-&gt;formRow($form-&gt;get('docs'));
  echo $this-&gt;formRow($form-&gt;get('submit'));
  echo $this-&gt;form()-&gt;closeTag();
  ?&gt;
  </code></pre>