问题
I use cakePHP 3 and I have a sign in form with Form->input(). If on purpose I make an error, this error doesn't whow up under the Form field. It doesn't appear anywhere.
My code is like this:
$newUser = $this->Users->newEntity($this->request->data());
if (!$this->Users->save($newUser)) {
debug($newUser->errors());
$this->Flash->error('Error');
return;
}
Debug show the errors, but shouldn't they appear under each form element automatically?
回答1:
ok I found the error. I wasn't passing in Form->create the entiry but null. I did it like
$this->Form->create($entity...
and works nicely.
来源:https://stackoverflow.com/questions/32936259/cakephp-3-and-form-validation-errors