Zend2注释和文件验证器


Zend 2 annotations and file validators

是否可以使用带有表单注释的文件验证类?

/**
 * @Form'Name("profile_avatar")
 * @Form'Type("Zend'Form'Element'File")
 * @Form'Options({"label":"Your avatar"})
 * @Form'Validator({"name":"Zend'Validator'File'IsImage"})
 */
public $profile_avatar;

使用上面的代码,即使您发送的是非图像文件,表单也始终有效。

我认为你必须只使用"IsImage"作为名称。。。我对Hostname valuidator也有类似的问题。事实上,我没有解决它,因为我无法让选项发挥作用。。。