I am getting validation errors in controller (from rules set in the respective model file) , but unable to make them automatically display below their respective input fields in view file.(as those were shown in Cake 2.0 versions)
Here is Controller function i have used for editing a user:
public function edit($user_id = null) {
$user = $this->Users->get($user_id);
if ($this->request->is(‘post’)) {
$user= $this->Users->patchEntity($user, $this->request->data);
if (empty($user->errors())) {
$this->Users->save($user);
} else {
$this->set(‘errors’, $user->errors());
}
} else {
$this->request->data = $user;
}
$this->set(‘user’,$user);
}
VIEW FILE:
Example block-level help text here.
</div>
</section>
</div>
UserTable.php
<?php namespace App\Model\Table; use Cake\ORM\Table; use Cake\Validation\Validator; //use Cake\ORM\RulesChecker; class UsersTable extends Table { public function validationDefault(Validator $validator) { return $validator ->notEmpty( 'username', 'Please Enter your Username.' ) ->notEmpty( 'name', 'Please Enter your name.' ) ->notEmpty( 'email', 'Please Enter your Email Address.' ) ->add( 'email', ['unique' => [ 'rule' => 'validateUnique', 'provider' => 'table', 'message' => 'Email Already Exists'] ] ) ->notEmpty('password', 'Please Enter your password.') ->notEmpty('confirm_password', 'Please ReConfirm your password.') ; } function initialize(array $config) { parent::initialize($config); $this->addBehavior('Timestamp'); } ---- so how to show those errors automatically in view file below the input fields?