我花了几个小时用这个把我的头撞在墙上。无论如何,我的表单字段的标签都没有出现。Zend Framework 2表单注释被忽略,没有额外的空间
最后发现,如果没有光标所在的额外空间(请参见图片),所有注释都会被忽略。我使用ZF 2.1.1和Doctrine Common 2.2.3。
我做错了什么?或者这是ZF还是Doctrine解析器中的错误?
作品:
class LoginForm
{
/** @Annotation\Type("text")
* @Annotation\Options({"label":"Store ID:"})
* @Annotation\Required(true)
* @Annotation\Filter({"name":"StringTrim"})
* @Annotation\Validator({"name":"StringLength","options":{"min":2,"max":64}})
*/
public $sStoreId;
}
失败,除非有一个空间之后/ **:
class LoginForm
{
/**
* @Annotation\Type("text")
* @Annotation\Options({"label":"Store ID:"})
* @Annotation\Required(true)
* @Annotation\Filter({"name":"StringTrim"})
* @Annotation\Validator({"name":"StringLength","options":{"min":2,"max":64}})
*/
public $sStoreId;
}
我将所有的@Annotations都忽略了。我投入@Annotation \ ErrorCheckThisIsPoorlyMade()没有发生错误。是什么赋予了? – cr125rider 2013-03-06 23:19:27
另外,我确实发现我必须添加使用Zend \ Form \ Annotation; 到班级的顶部。它在注释中使用快捷键“Annotation”,您需要为该类定义命名空间。 – cr125rider 2013-03-13 14:28:29
是的,需要'使用Zend \ Form \ Annotation;'。 – Arthur 2013-03-13 14:33:47