::buildView()必须与Symfony\Component\Form\FormTypeInterface::buildView()的兼容

::buildView()必须与Symfony\Component\Form\FormTypeInterface::buildView()的兼容,symfony,symfony-forms,Symfony,Symfony Forms,我正试图为我的Symfony2表单实现一个自定义字段类型,但无论出于何种原因,我都会遇到一个致命错误,如本问题标题所述。 我已经从接口复制了原始声明,但没有用:-( 以下是解决您问题的方法 原因很可能是您没有使用所需的参数类型 use Symfony\Component\Form\AbstractType, use Symfony\Component\Form\FormViewInterface; use Symfony\Component\Form\FormInterface; //...

我正试图为我的Symfony2表单实现一个自定义字段类型,但无论出于何种原因,我都会遇到一个致命错误,如本问题标题所述。
我已经从接口复制了原始声明,但没有用:-(

以下是解决您问题的方法

原因很可能是您没有使用所需的参数类型

use Symfony\Component\Form\AbstractType,
use Symfony\Component\Form\FormViewInterface;
use Symfony\Component\Form\FormInterface;

//...
class SomeType extends AbstractType
{
    public function buildView(FormViewInterface $view, FormInterface $form, array $options)
}

嗨,Marco,FormViewInterface成功了。我已经试过了,但你链接的答案中没有出现这个。非常感谢:-)
use Symfony\Component\Form\AbstractType,
use Symfony\Component\Form\FormViewInterface;
use Symfony\Component\Form\FormInterface;

//...
class SomeType extends AbstractType
{
    public function buildView(FormViewInterface $view, FormInterface $form, array $options)
}