布尔值作为复选框


Boolean value as checkbox

我想添加一个布尔值到我的实体。

它看起来像这样:

namespace MyModule'MyClass'Entity;
use Doctrine'ORM'Mapping as ORM;
use Zend'Form'Annotation as Form;
/**
 * @ORM'Entity
 * @ORM'Table(name="mymodule_myclass")
 * @Form'Name("myclass")
 * @Form'Attributes({ "class": "form-horizontal" })
*/
class MyClass
 ...
 /**
 * @ORM'Column(type="boolean")
 * @Form'Attributes({"type":"checkbox"})
 * @Form'Options({"label":"Revised"})
 *
 */
protected $revised = false;

当然我想把这个变量显示为一个复选框。所以我添加了@Form'Attributes

不幸的是我得到了

"NetworkError: 500 Internal Server Error"

知道为什么会这样,我能做些什么来修复它吗?

BTW:每个Firebug手动更改type属性会将输入字段变成一个复选框…

解决方案是使用end- checkbox,而不改变输入的类型。

/**
 * @ORM'Column(type="boolean")
 * @Form'Options({"label":"My Boolean*"})
 * @Form'Type("Zend'Form'Element'Checkbox")
 */
protected $my_bool;