是否有任何示例显示如何将输入筛选器应用于字段集


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

我正在创建一个用于文件上传的模块,该模块本质上将提供一个 FieldSet 和一个视图帮助程序来显示小部件。

我要求字段集具有单独的输入过滤器,

但我正在努力在框架中找到任何功能来将输入过滤器与字段集相关联。

你必须

实现InputFilterProviderInterface。请参阅下面的示例

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
          )
       );
   }
}

绝对需要告诉表单实际验证字段集。我个人是这样做的:

class BarForm extends Form
{
    public function __construct()
    {
         // other stuff, add elements and fieldset
         $this->setValidationGroup(array(
             'someElement',
             'someFieldset' => array(
                 'fieldSetElement#1',
                 'fieldSetElement#2'
             )
         ));
    }
}

如果这太抽象了,请告诉我,我将使用真实世界的示例对其进行编辑。应该足以让你走,虽然我想;)