0

I am trying to save the data but in error() it is not showing anything but still save() method returns false. After some research i figure out it is due to failure of buildRule

 public function buildRules(RulesChecker $rules)
{
    //$rules->add($rules->isUnique(['email']));
    $rules->add($rules->existsIn(['religion_id'], 'MsReligions'));
     $rules->add($rules->existsIn(['applicant_permanent_state_id']));
    return $rules;
}

Did anyone know how to view buildrules error in cakephp 3.2 error() method is only showing validations error.

  • `existsIn` needs to be told where the ID should be looked for; your first call has it, but the second doesn't. – Greg Schmidt Oct 11 '16 at 15:22
  • i want to debug build rules in controller so that i can see if which build rule fails – vinit dhull Oct 13 '16 at 05:43
  • Somebody else will have to help you with that. I'm saying that in this case `$rules->add($rules->existsIn(['applicant_permanent_state_id']));` needs a second parameter to tell it what table it should be looking for `applicant_permanent_state_id` in. – Greg Schmidt Oct 13 '16 at 14:47
  • I just took a quick look at the implementation of the `existsIn` function, and it requires at least two parameters. If you have debugging turned on, you should be getting a PHP error, or at least warning, about this. And you should get more error messages thrown when the `save` function tries to use this. There is nothing in your entity's errors, because the error is not in the data but rather in the code. – Greg Schmidt Oct 13 '16 at 20:21

0 Answers0