【问题标题】:Expected argument of type "string", "AppBundle\Form\MovieType" given给定“字符串”、“AppBundle\Form\MovieType”类型的预期参数
【发布时间】:2017-06-23 10:01:27
【问题描述】:

我被这个错误困住了:/

问题出在哪里?我对使用 PHP 的 symfony 很陌生...如果有人可以帮助我,那就太好了:)

class MovieType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array                      $options)
{
    $builder->add('title', TextType::class)
            ->add('samsCharacterName', TextType::class)
            ->add('isMainCharacter', CheckboxType::class, array(
                required => false
            ))
            ->add('rating', IntegerType::class)
            ->add('releasedAt', DateType::class, array(
                'widget' => 'single_text'
            ));
}

public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'AppBundle\Entity\Movie'
    ));
}

public function getBlockPrefix()
{
    return 'app_bundle_movie_type';
}

}

【问题讨论】:

  • 不清楚错误是在哪里引发的或者你在哪里使用这种方式,无论如何检查你是否使用::class符号作为示例:$form = $this->createForm(MovieType::class, $movie);

标签: php forms symfony phpstorm symfony-forms


【解决方案1】:

不清楚错误是在哪里引发的,或者您在哪里使用这种方式,无论如何检查您是否使用::class 符号作为示例创建:

$form = $this->createForm(MovieType::class, $movie); 

更多信息here在文档中。

希望有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    • 2017-04-11
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多