In Cakephp we have a function
public function buildRules(RulesChecker $rules) {
$rules->add($rules->existsIn(['supplier_id'], 'Suppliers'));
}
this Returns a rules checker object that will be used for validating application integrity. http://book.cakephp.org/3.0/pt/orm/saving-data.html#applying-application-rules
but when we have a field that is not required like supplier_id
->add('supplier_id', 'valid', ['rule' => 'numeric'])
->allowEmpty('supplier_id')
but has a integrity check on buildRules this will fail on edit action , when i try to change this field to empty as save it.
Note: This only happens after we put a value on this field and then we edit it, put a empty value and then save it again ( its here that the save fails )