У меня есть проблема с простой функцией регистрации в торт php 4, я включил компонент FormProtection, и он возвращает «_Token не был найден в данных запроса».
Токен уже сгенерирован, но я не знаю, почему контроллер не может его обнаружить
<?= $this->Form->create($user,['class' => '']) ?>
<?= $this->Flash->render('signup') ?>
<div class="inp-row">
<label for="">Full Name</label>
<?= $this->Form->input('name',["placeholder"=>"Your full name",'label'=>false,'required'=>true,'class' => '']) ?>
</div>
<div class="inp-row">
<label for="">Email Address</label>
<?= $this->Form->input('username',["placeholder"=>"Your email address",'label'=>false,'required'=>true,'type'=>'email','class' => '']) ?>
</div>
<div class="inp-row">
<label for="">Password</label>
<?= $this->Form->input('password',["placeholder"=>"Type your password",'label'=>false,'id'=>"pass_change" ,'required'=>true,'type'=>'password','class' => '']) ?>
</div>
<?= $this->Form->button(__('Sign up'));?>
<?= $this->Form->end() ?>
Регистрация функции
$user = $this->Users->newEmptyEntity();
if ($this->request->is('post')) {
$user = $this->Users->patchEntity($user, $this->request->getData());
if ($this->Users->save($user)) {
$this->Flash->success(__("Your account has been created successfully."), [ 'key' => 'signup']);
}
}
$this->set('user', $user);
2020-05-05 23:48:32 Error: [Cake\Http\Exception\BadRequestException] `_Token` was not found in request data. in xxxxxx/vendor/cakephp/cakephp/src/Controller/Component/FormProtectionComponent.php on line 141
Stack Trace:
- xxxxxx/vendor/cakephp/cakephp/src/Controller/Component/FormProtectionComponent.php:95
- xxxxxx/vendor/cakephp/cakephp/src/Event/EventManager.php:309
- xxxxxx/vendor/cakephp/cakephp/src/Event/EventManager.php:286
- xxxxxx/vendor/cakephp/cakephp/src/Event/EventDispatcherTrait.php:92
- xxxxxx/vendor/cakephp/cakephp/src/Controller/Controller.php:569
- xxxxxx/vendor/cakephp/cakephp/src/Controller/ControllerFactory.php:72
- xxxxxx/vendor/cakephp/cakephp/src/Http/BaseApplication.php:229
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:77
- xxxxxx/vendor/cakephp/cakephp/src/Http/Middleware/BodyParserMiddleware.php:164
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:73
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:77
- xxxxxx/vendor/cakephp/cakephp/src/Http/Middleware/CsrfProtectionMiddleware.php:137
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:73
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:58
- xxxxxx/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php:162
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:73
- xxxxxx/vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php:68
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:73
- xxxxxx/vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php:119
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:73
- xxxxxx/vendor/cakephp/cakephp/src/Http/Runner.php:58
- xxxxxx/vendor/cakephp/cakephp/src/Http/Server.php:90
- xxxxxx/webroot/index.php:40