作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在我的项目中使用 gregwarCaptchaBundle,我收到以下错误消息:Could not load type "Symfony\Component\Form\Extension\Core\Type\TextType"
详细信息:
at FormRegistry ->getType ('Symfony\Component\Form\Extension\Core\Type\TextType')
in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php at line 121 +
at FormRegistry ->resolveAndAddType (object(CaptchaType))
in vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php at line 86 +
at FormRegistry ->getType ('captcha')
in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 82 +
at FormFactory ->createNamedBuilder ('captcha', 'captcha', null, array('distortion' => false, 'reload' => true, 'as_url' => true, 'humanity' => '1000'))
in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 106 +
at FormBuilder ->create ('captcha', 'captcha', array('distortion' => false, 'reload' => true, 'as_url' => true, 'humanity' => '1000'))
in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 267 +
at FormBuilder ->resolveChildren ()
in vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 215 +
at FormBuilder ->getForm ()
in vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 39 +
at FormFactory ->create (object(RatingForm), null, array())
in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 250 +
at Controller ->createForm (object(RatingForm))
in vendor/xxBundle/RatingBundle/pp/RatingBundle/Controller/DefaultController.php at line 63 +
at DefaultController ->renderRatingInterfaceAction (object(Request), 'Profil', '3209', true, false, true, '5')
...
表单类型的代码是这样的:
<?php
...
public function setUser($user) {
$this->user = $user;
}
public function setSession($session) {
if (!is_null($session)) {
$sessionBlocked = $session->get(sprintf('gcb_%s', 'captcha') . '_humanity');
$this->sessionBlocked = $sessionBlocked;
}
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
//$user = $builder->getData()->getUser();
$builder->setMethod('post');
$builder->setAction('');
$builder->add('commenctcontent', 'textarea', array(
'required' => true,
))
->add('name','text',array(
'required' => true,
))
->add('email','text',array(
'required' => true,
));
if(!is_object($this->user)){
$options = array(
'distortion' => false,
'reload' => true,
'as_url' => true,
'humanity' => 1000,
);
$builder->add('captcha', 'captcha', $options);
}
$builder->add('starratevalue','hidden');
}
...
}
找不到任何错误或错误代码。神秘的是:我在另一个项目中使用了完全相同的代码。在另一个项目中,它工作得很好。
最佳答案
GregwarCaptchaBundle 正在尝试通过其完全限定的类名加载验证码表单类型的基类型。这是 Symfony 2.8 中添加的功能,并且是 3.0 中的默认功能。用this commit , bundle 与 Symfony 3.0 兼容,但与 Symfony 2.7 不兼容。使用版本 v1.0.12 而不是版本 v1.0.13 应该可以解决问题。
编辑: Following some discussion在 bundle 的问题队列中。作者删除了 v.1.0.13 标签并添加了 v2.0 标签。新的兼容性信息指出:
关于php - GregwarCaptchaBundle : TextType could not been loaded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34204066/
我在我的项目中使用 gregwarCaptchaBundle,我收到以下错误消息:Could not load type "Symfony\Component\Form\Extension\Core\
我是一名优秀的程序员,十分优秀!