Are there any examples that show how to apply an InputFilter to a Fieldset?

I am creating a module for file uploading which will essentially provide a FieldSet and a view helper to display a widget.

I require a the Fieldset to have a separate InputFilter but I'm struggling to find any functionality in the framework to relate an InputFilter to a Fieldset.

Answers


You have to implement the InputFilterProviderInterface. See my example below

use Zend\InputFilter\InputFilterProviderInterface;

class FooFieldset extends Fieldset implements InputFilterProviderInterface
{
   public function __construct() { // add elements }

   public function getInputFilterSpecification()
   {
       return array(
          'elementName' => array(
              'filters' => array(),
              'validators' => array(),
              'properties' => array(),
              'required' => true
          )
       );
   }
}

It is absolutely required though that you tell the form to actually validate your fieldset. Personally i do it like this:

class BarForm extends Form
{
    public function __construct()
    {
         // other stuff, add elements and fieldset

         $this->setValidationGroup(array(
             'someElement',
             'someFieldset' => array(
                 'fieldSetElement#1',
                 'fieldSetElement#2'
             )
         ));
    }
}

If this is too abstract let me know and I'll edit this using a real-world example. Should be enough to get you going though i guess ;)


Need Your Help

How to allign grid of bootstrap 3 in center for extremely smalls screens

css twitter-bootstrap-3 alignment

I am trying to align column1 in center for extremely small screens. I have searched alot on internet. I have also used center-block class but it doesnt work.

Errors in Layout Cant figure it out

java android eclipse

I have created four tabs with listview in each. I have been attempting to make the list views clickable, I have used the listview tutorial from Here to create the list view using string.xml and R....