首页 文章

如何在从Symfony 2.8更新到Symfony 3.x之前修复表格DeprecatedWarning?

提问于
浏览
0

关于从symfony2.8到symfony3.x的更新过程,我有一个小问题 . 我有很多已弃用的警告,在我开始更新之前我想修复它 .

但我无法修复它,因为似乎某些(新)功能在2.8版本中不可用 . 可能吗?

例如:

Accessing type "text" by its string name is deprecated since Symfony 2.8 and will be removed in 3.0. Use the fully-qualified type class name "Symfony\Component\Form\Extension\Core\Type\TextType" instead. (3 times)  Show stack trace

这意味着,我应该自定义我的表单:

->add('birthyear', 'text', array(
            'label' => 'Year of birth',
            'attr' => array('placeholder'=>'yyyy'),
            'required' => false,
    ))

至...

->add('birthyear', Symfony\Component\Form\Extension\Core\Type\TextType:class, array(
            'label' => 'Year of birth',
            'attr' => array('placeholder'=>'yyyy'),
            'required' => false,
    ))

但是我的当前版本中不存在此文件夹或路径 .

Symfony\Component\Form\Extension\Core\Type\TextType

我应该在更新后修复它吗?或者我必须做哪些变通办法?我很困惑,因为在Symfony doc中写道“你应该先修复它” .

感谢您的反馈!

1 回答

  • 1
    use Symfony\Component\Form\Extension\Core\Type\TextType;
    
    ->add('birthyear', TextType::class, array(
                'label' => 'Year of birth',
                'attr' => array('placeholder'=>'yyyy'),
                'required' => false,
        ))
    

相关问题