title: zf add inputfilter for a new fieldset element in the form class
body: <p>In zend framework, how do I add an inputfilter for a new form element in a fieldset with the code in the form?  In the following case, I've defined a set of common form elements and an inputfilter for those elements in a fieldset class, and add the fieldset to the form.  After that, I add one or more new form elements to the fieldset in the form code (I'm doing it in the form and not in the fieldset to prepare to add elements dynamically by form factory). What I'm having trouble with is adding new inputfilter definitions for the additional elements.</p>
  
  <p>in my fieldset:</p>
  
  <pre><code>class myFieldset extends Fieldset implements InputFilterProviderInterface
  {
      public function init()
      {
  
          // add form elements
  
      }
  
      public function getInputFilterSpecification()
      {
  
          $inputFilter['myFormElement'] = [
              'required' =&gt; true,
              'filters'  =&gt; [[ ... ],],
              'validators' =&gt; [[ ... ],],             
              'allow_empty' =&gt; false,
              'continue_if_empty' =&gt; false,
          ];
  
          // more filters
  
          return $inputFilter;
  
      }   
  
  }
  </code></pre>
  
  <p>in my form:</p>
  
  <pre><code>class myForm extends Form
  {
  
      public function __construct()
      {
          // ...
  
          // add elements from fieldset
          $this-&gt;add([
              'name' =&gt; 'myFieldset',
              'type' =&gt; 'Application\Form\Fieldset\myFieldset',
              'options' =&gt; [
                  'use_as_base_fieldset' =&gt; true,
              ],
          ]);
  
          // add new element
          $myFieldset = $this-&gt;get('myFieldset');
          $myFieldset-&gt;add([
              'name' =&gt; 'additionalElement',
              'type' =&gt; 'Zend\Form\Element\ ... ',
              'attributes' =&gt; [],
              'options' =&gt; [],
          ]);
  
          // update inputfilter
          $input = new Input('additionalElement');
          $input-&gt;setRequired(false);
  
          $currentInputFilter = $this-&gt;getInputFilter();
          $currentInputFilter-&gt;add($input); 
          $this-&gt;setInputFilter($currentInputFilter);
  
          // submit buttons
  
      }
  
  }
  </code></pre>
  
  <p>In this example, the additional element gets added to the fieldset, but I've got the code wrong to add new definitions to the inputfilter.</p>