I'm trying to build an Entity with a "xml" text field that must insert in the database the concatenation of other fields from the same entity. It looks like this (without annotations) :
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;
}
I try to insert those values using a simple form like this :
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('description')
->add('xml', 'hidden')
;
}
When I try to submit the form, I've got an error saying my xml value is null. "An exception occurred while executing 'INSERT INTO Category (title, description, xml) VALUES (?, ?, ?, ?)' with params ["Title 1", "Desc 1", null]:"
What am I doing wrong ?