我正在尝试使用“xml”文本字段构建一个实体,该文本字段必须在数据库中插入来自同一实体的其他字段的串联。它看起来像这样(没有注释):
class Category
{
private $id;
private $title;
private $description;
public function getId()
{
return $this->id;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function getTitle()
{
return $this->title;
}
public function setDescription($description)
{
$this->description = $description;
return $this;
}
public function getDescription()
{
return $this->description;
}
public function setXml($xml)
{
$xml = $this->id;
$xml += $this->title;
$xml += $this->description;
return $xml;
}
public function getXml()
{
return $this->xml;
}
我尝试使用这样的简单形式插入这些值:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('description')
->add('xml', 'hidden')
;
}
当我尝试提交表单时,我收到一条错误消息,提示我的 xml 值为空。 “使用参数 ["Title 1", "Desc 1", null] 执行 'INSERT INTO Category (title, description, xml) VALUES (?, ?, ?, ?)' 时发生异常:"
我究竟做错了什么 ?