0
votes

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 )

1
Open a ticket, this looks like an omission when dealing with nullable columns - José Lorenzo Rodríguez

1 Answers

0
votes

If you only want to check for integer and notEmpty then what is the need of creating a buildRules function? You can directly do that and it will work in all conditions.