我正在使用 zend framework-2 中的 Annotation 类创建一个表单。在这门课中,我尝试使用注释创建日期字段,但它没有显示在表单上。请帮助我如何使用注释设置 vdate 字段属性。
代码TestEntity.php
<?php
namespace TestAjax\Model;
use Zend\Form\Annotation;
/*
* @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
* @Annotation\Name("TestEntity")
*/
class TestEntity
{
/**
* @Annotation\Type("Zend\Form\Element\Date")
* @Annotation\Required({"required":"true" })
* @Annotation\Filter({"name":"vdate"})
* @Annotation\Validator({"name":"Between", "options":{"min":"1970-01-01" "max":"2013-12-31"}})
* @Annotation\Options({"label":"Date:"})
*/
public $vdate;
/**
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Required({"required":"true"})
* @Annotation\Filter({"name":"StripTags"})
* @Annotation\Validator({"name":"StringLength", "options":{"min":"5"}})
* @Annotation\Options({"label":"Last Name:"})
*/
public $lastname;
/**
* @Annotation\Type("Zend\Form\Element\Radio")
* @Annotation\Required({"required":"true" })
* @Annotation\Filter({"name":"StripTags"})
* @Annotation\Options({"label":"Gender:",
* "value_options" : {"1":"Male","2":"Female"}})
* @Annotation\Validator({"name":"InArray",
* "options":{"haystack":{"1","2"},
* "messages":{"notInArray":"Gender is not valid"}}})
* @Annotation\Attributes({"value":"1"})
*/
public $gender;
/**
* @Annotation\Type("Zend\Form\Element\Select")
* @Annotation\Required({"required":"true" })
* @Annotation\Filter({"name":"StripTags"})
* @Annotation\Options({"label":"Class:",
* "value_options" : {"0":"Select a Class","1":"A","2":"B","3":"C"}})
* @Annotation\Validator({"name":"InArray",
* "options":{"haystack":{"1","2","3"},
* "messages":{"notInArray":"Please Select a Class"}}})
* @Annotation\Attributes({"value":"0"})
*/
public $class;
/**
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Required({"required":"true" })
* @Annotation\Filter({"name":"StripTags"})
* @Annotation\Options({"label":"Username:"})
*/
public $username;
/**
* @Annotation\Type("Zend\Form\Element\Password")
* @Annotation\Required({"required":"true" })
* @Annotation\Filter({"name":"StripTags"})
* @Annotation\Options({"label":"Password:"})
*/
public $password;
/**
* @Annotation\Type("Zend\Form\Element\Submit")
* @Annotation\Attributes({"value":"Submit"})
*/
public $submit;
}