You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Symfony version(s) affected: 5.1.6 (same with 5.1.5)
Description
typehinting DateTime in a Form cause bugs...
If you dont put a value in a DateType in a Form, you have a Exception (Typed property App\Form\BugForm::$date must be an instance of DateTime, null used) with php 7.4 typed definition of the date (public \DateTime $date;) in place of a error message in the form.
How to reproduce
class BugForm
{
/**
* @Assert\NotNull()
*/
public \DateTime $date;
}
class BugType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('date', DateType::class, ['widget' => 'single_text']);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'attr' => ['novalidate' => 'novalidate'],
'data_class' => BugForm::class,
]
);
}
}
To have the normal comportment, just dont use php 7.4 typed definition ("public $date" instead of "public \DateTime $date")
The text was updated successfully, but these errors were encountered:
Symfony version(s) affected: 5.1.6 (same with 5.1.5)
Description
typehinting DateTime in a Form cause bugs...
If you dont put a value in a DateType in a Form, you have a Exception (Typed property App\Form\BugForm::$date must be an instance of DateTime, null used) with php 7.4 typed definition of the date (public \DateTime $date;) in place of a error message in the form.
How to reproduce
class BugForm
{
}
class BugType extends AbstractType
{
}
To have the normal comportment, just dont use php 7.4 typed definition ("public $date" instead of "public \DateTime $date")
The text was updated successfully, but these errors were encountered: