Я новичок в CakePHP и только начинаю с примеров CookBook. Теперь я хочу создать простую регистрационную форму и форму входа с моими столбцами таблицы custome. Но система не хочет вставлять данные! Где моя ошибка? Правильно ли сказать ему в AppController, какие поля использовать?cakePHP регистрация не работает
add.ctp =
<div class="users_form">
<?= $this->Form->create($user) ?>
<fieldset>
<legend><?= __('Add') ?></legend>
<?= $this->Form->input('username') ?>
<?= $this->Form->input('password') ?>
</fieldset>
<?= $this->Form->button(__('Submit')); ?>
<?= $this->Form->end() ?>
UsersTable.php
class UsersTable extends Table{
public function initialize(array $config)
{
parent::initialize($config);
$this->table('ab_login');
}
public function validationDefault(Validator $validator)
{
return $validator
->notEmpty('username', 'insert name')
->notEmpty('password', 'pw insert');
}
}
AppController.php
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'fields' => ['username' => 'ab_mail', 'password' => 'ab_pass']
]
]
]);
UsersController.php
public function add()
{
$user = $this->Users->newEntity();
if ($this->request->is('post'))
{
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user))
{
$this->Flash->success(__('inserted!'));
return $this->redirect(['action' => 'add']);
}
$this->Flash->error(__('Error!'));
}
$this->set('user', $user);
}
исправлено. Если кто-то заинтересован в решении, просто добавьте комментарий. – Ckappo