带有 ajax 的 CRUD SonataAdmin 在迁移之前不起作用



我想就使用Symfony 3.1的项目向我寻求帮助,我正在更新到3.4。 O composer.json 是这样的:

"require" : {
"php" : ">=5.5.9",
"symfony/symfony" : "3.1.*",
"doctrine/orm" : "^2.5",
"doctrine/doctrine-bundle" : "^1.6",
"doctrine/doctrine-cache-bundle" : "^1.2",
"symfony/swiftmailer-bundle" : "^2.3",
"symfony/monolog-bundle" : "^2.8",
"symfony/polyfill-apcu" : "^1.0",
"sensio/distribution-bundle" : "^5.0",
"sensio/framework-extra-bundle" : "^3.0.2",
"incenteev/composer-parameter-handler" : "^2.0",
"symfony/form" : "^3.1.0",
"twbs/bootstrap" : "^3.3",
"symfony/assetic-bundle" : "^2.8",
"components/jquery" : "^3.0",
"sonata-project/admin-bundle" : "^3.3",
"sonata-project/doctrine-orm-admin-bundle" : "^3.0",
"jms/serializer-bundle" : "^1.1",
"friendsofsymfony/jsrouting-bundle" : "2.0.0-alpha1",
"friendsofsymfony/user-bundle" : "dev-master#c62c727dc7a387edc16df32d2ee4181e620ad35f",
"setasign/fpdf" : "1.8.1",
"knplabs/knp-snappy-bundle" : "^1.4",
"knplabs/knp-paginator-bundle" : "2.5.3",
"endroid/qrcode" : "^1.9"
}

我改成了:

"require" : {
"php" : ">=7.2",
"symfony/symfony" : "3.4.*",
"doctrine/orm" : "^2.6",
"doctrine/doctrine-bundle" : "^1.9",
"doctrine/doctrine-cache-bundle" : "^1.3",
"symfony/swiftmailer-bundle" : "^3.2",
"symfony/monolog-bundle" : "^3.3",
"symfony/polyfill-apcu" : "^1.9",
"sensio/distribution-bundle" : "^5.0",
"sensio/framework-extra-bundle" : "^5.0.2",
"incenteev/composer-parameter-handler" : "^2.1",
"symfony/form" : "^3.4",
"twbs/bootstrap" : "^4.1",
"symfony/assetic-bundle" : "^2.8",
"components/jquery" : "^3.3",
"sonata-project/admin-bundle" : "^3.39",
"sonata-project/doctrine-orm-admin-bundle" : "^3.6",
"jms/serializer-bundle" : "^2.4",
"friendsofsymfony/jsrouting-bundle" : "2.2.0",
"friendsofsymfony/user-bundle" : "^2.1",
"setasign/fpdf" : "1.8.1",
"knplabs/knp-snappy-bundle" : "^1.5",
"knplabs/knp-paginator-bundle" : "^2.8",
"endroid/qrcode" : "^1.9"
}

但是访问使用 ajax 的奏鸣曲形式需要多长时间就会失败: 找不到模板 " (查看:/var/www/html/dhui/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views,/var/www/html/dhui/app/Resources/views,/var/www/html/dhui/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form(。

故障发生在有此功能的位置:

class TesteAdmin extends AbstractAdmin
{
/**
* Altera o template padrão do admin para o template com AJAX
*/
public function getTemplate($name)
{ dump($this->templates); exit;
if (isset($this->templates[$name])) {
if ($name === 'edit') {
return 'TesteBundle:Anotacao:base_edit.html.twig';
} else {
return $this->templates[$name];
}
}
}

People,

为了解决这个问题,我做了以下工作:

class TesteAdmin extends AbstractAdmin
{
public function getTemplate($name)
{ 
if ($name === 'edit') {
return 'TesteBundle:Anotacao:base_edit.html.twig';
} else {
return parent :: getTemplate($name);
}
}
}

相关内容

  • 没有找到相关文章

最新更新