I can't pass a null value through the validation of my form, this is my code (I'll only show you the necessary part of the code) :
Form :
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('text', TextType::class , array(
'required' => false,
'empty_data' => null,
))
}
My entity (it's a Trait) :
trait TextTrait
{
/**
* @ORM\Column(type="text", nullable=true)
*/
private $text = null;
/**
* Set text
*
* @param string $text
*/
public function setText(?string $text = null)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText() : ?string
{
return $this->text;
}
}
The error :
How can i pass a null variable in a symfony form ??