php - CakePHP, Changing data only for a specific rule in beforeValidation -
i save ip numeric value in database. when fetch use virtualfield , inet_ntoa sql expression.
i want ip unique, therefore use isunique validation rule in model. problem rule validates ip address against numeric value in db.
is there way can modify value of field rule before validation? other rule "ip" needs ip address not numeric value.
i'd suggest create custom validation rule checks if converted ip unique.
… 'rule' => 'ipisunique', … // customize needed public function ipisunique($data) { return $this->isunique(array_map('ip2long', $data)); }
Comments
Post a Comment