有没有办法使用复选框表单类型与已设置为字符串的字段?
此字段可以包含许多值,可用于将数据作为文本字段或复选框输入.
我在formtype上有一个事件监听器来检查它是否应该是一个复选框或文本字段.
/Entity.php
/**
* @var string
*
* @ORM\Column(name="value", type="string", length=200, nullable=true)
*/
private $value;
Run Code Online (Sandbox Code Playgroud)
formtype.php
$form->add('value', 'checkbox', array(
))
Run Code Online (Sandbox Code Playgroud)
错误
Unable to transform value for property path "value": Expected a Boolean.
Run Code Online (Sandbox Code Playgroud)
小智 6
Entity.php
public function getValue()
{
return (boolean)$this->value;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3960 次 |
| 最近记录: |