I have a Symfony2 form with a variety of fields, including one optional text field called recap
.
This recap
field saves perfectly when there\'s
Just came across similar error in Symfony2:
My entity:
/**
* @ORM\Column(type="boolean")
*/
protected $Valid;
My form:
$builder->add('Valid', 'hidden');
Now for true values, field is rendered correctly with value="1", but for false values field is rendered with value="", which leads to:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'Valid' cannot be null
While I would expect it to be rendered as value="0".
Of course setValid() method can be enhanced to set the right value:
public function setValid($valid)
{
$this->Valid = ($valid ? true : false);
}
Which work arounds the issue, not fixes it.