Я использую расширенный шаблон yii2 для создания сайта.
Когда я хочу использовать форму для создания новой строки, она работает, но во втором представлении или обновлении через пару секунд я получаю эту ошибку.
Я прочитал много ответов здесь, но я не хочу отключать токен crf и aleardy, который у меня есть
<?= Html::csrfMetaTags() ?>
на моем макете <head/>
любые предложения!?.
файл конфигурации:
use \yii\web\Request;
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
// Replace url
$request = new Request();
$baseUrlFront = str_replace('/backend/web', '/frontend/web', $request->getBaseUrl());
$scriptUrlFront = str_replace('/backend/web', '/frontend/web', $request->getScriptUrl());
return [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_backendUser', // unique for backend
'path'=>'/backend/web' , // correct path for the backend app.
]
],
'session' => [
'name' => 'regergwer2343423f238h923f9h9234', // unique for backend
'savePath' => __DIR__ . '/../runtime', // a temporary folder on backend
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'i18n' => [
'translations' => [
'writesdown' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages', // if advanced application, set @frontend/messages
'sourceLanguage' => 'en',
'fileMap' => [
//'main' => 'main.php',
],
],
],
],
'urlManagerFront' => [
'class' => 'yii\web\urlManager',
'scriptUrl' => $scriptUrlFront,
'baseUrl' => $baseUrlFront,
],
'urlManagerBack' => [
'class' => 'yii\web\urlManager',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
],
'params' => $params,
];
расположение:
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<?= Html::csrfMetaTags() ?>
<title>WritesDown » <?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body
class="<?= isset(Yii::$app->params['bodyClass']) ? Yii::$app->params['bodyClass'] : "skin-blue sidebar-mini"; ?>">
<?php $this->beginBody() ?>
<?= $content; ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>