来自2.5.9的Symfony Form Type不再被识别,尽管仍在使用2.5.9



我正在使用Symfony 2.5.9,最近运行了composer update。在带有表单的页面上,我现在得到:

InvalidArgumentException: 无法加载类型 "Symfony\Component\Form\Extension\Core\Type\TextType" (0)

在更新之前,该页面呈现良好。形式是

use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentOptionsResolverOptionsResolverInterface;
use SymfonyComponentFormFormBuilderInterface;
use SymfonyComponentFormAbstractType;
use SymfonyComponentFormFormBuilder;
use SymfonyComponentYamlYaml;
use SymfonyComponentFormFormEvents;
use SymfonyComponentFormFormEvent;
use SymfonyComponentFormFormError;
class TaskType extends AbstractType {
  public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('name')
                ->add('info', 'text', array());
    }
  public function getName() {
        return 'myapp_mybundle_tasktype';
    }
    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'MyAppMyBundleEntityTask'
        ));
    }
}

阅读其他一些帖子,这似乎是因为在Symfony 3中不再使用上述创建表单元素类型的方法。但是我现在需要使用 2.5.9。

即使我从主分支复制并粘贴 composer.json(即不受影响且正常工作)并运行composer update,我也会收到同样的错误。

我还尝试从供应商文件夹中删除所有内容并刷新两个缓存,然后重新运行composer update但页面加载时出现相同的错误。这怎么可能?与其使用解决方法,还有什么原因需要更改?我仍然在开发工具栏中看到Symfony 2.5.9。

作曲家文件:

{
    "autoload": {
        "psr-0": {
            "": "src/"
        },
        "classmap": ["vendor/MediovskiTechnology/php-crontab-manager/src/"]
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.5.9",
        "symfony/console": "2.5.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "1.2",
        "twig/extensions": "1.1.*@dev",
        "symfony/assetic-bundle": "2.3.*",
        "symfony/swiftmailer-bundle": "2.3.7",
        "symfony/monolog-bundle": "2.6.*",
        "sensio/distribution-bundle": "3.0.*",
        "sensio/framework-extra-bundle": "3.0.*",
        "sensio/generator-bundle": "2.3.*",
        "jms/security-extra-bundle": "1.5.*",
        "jms/di-extra-bundle": "1.4.*",
        "kriswallsmith/assetic": "~1.1",
        "phpoffice/phpexcel": "1.8.0",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "doctrine/data-fixtures": "1.0.*@dev",
        "kriswallsmith/buzz": "dev-master",
        "mlpz/postmark-bundle": "dev-master",
        "friendsofsymfony/jsrouting-bundle": "2.0.*@dev",
        "jms/serializer-bundle": "*",
        "monolog/monolog": "1.10.0",
        "querypath/querypath": "dev-master",
        "MediovskiTechnology/php-crontab-manager": "0.9.3",
        "mtdowling/cron-expression": "1.1.0",
        "drak/native-session": "*",
        "egulias/email-validator": "~1.2",
        "swiftmailer/swiftmailer": "5.2.1",
        "twilio/sdk": "^5.4",
        "hybridauth/hybridauth": "2.6.0",
        "symfony/doctrine-bridge": "~2.7"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap"
        ],
        "post-update-cmd": [
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}

我通过更改来解决此问题

"doctrine/doctrine-fixtures-bundle": "dev-master",

"doctrine/doctrine-fixtures-bundle": "2.3.0",

相关内容

  • 没有找到相关文章

最新更新