したがって、DOBフィールドにnullオプションを送信できるようにします。ここで Symfony2 DateTime null accept
は私のフォームビルダーです:->add('birthDate', DateType::class, array(
'widget' => 'single_text',
'format' => 'yyyy-MM-dd'))
そして、ここに私のエンティティでこれらのフィールドである
/**
* @ORM\Column(
* type="date",
* nullable=true
*)
* @JMS\Groups("single")
*
* @var \DateTime
*/
protected $birthDate;
I`mは、私は、エラーMSGを得たヌルを送信しようとすると
Expected argument of type "DateTime", "NULL" given
アイデア?
CRITICAL - Uncaught PHP Exception Symfony\Component\PropertyAccess\Exception\InvalidArgumentException: "Expected argument of type "DateTime", "NULL" given" at /var/www/server.local/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php line 253
$type = $trace[$i]['args'][0];
$type = is_object($type) ? get_class($type) : gettype($type);
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given', substr($message, $pos, strpos($message, ',', $pos) - $pos), $type));
}
}
を得ている:あなたはデフォルト値としてセッターに
2.が
null
をしてみましょうこのエラー? – abdielフォームwhith birthDateフィールド –
を送信するときに、また、DBスキーマがエンティティと同期していることを確認しましたか? – Vamsi