Comments on “Learning CakePHP: Validation”http://robwilkerson.org/2009/07/31/learning-cakephp-validation/feed2009-09-29T09:07:00-04:00ChyrpLearning CakePHP: Validationtag:robwilkerson.org,2009-09-29:/id/176//comment_129872009-09-29T09:07:00-04:002009-09-29T09:07:00-04:00neelhttp://www.snilesh.com
<p>Nice article for the cakephp validation I am looking for this..</p> Learning CakePHP: Validationtag:robwilkerson.org,2009-07-31:/id/176//comment_110562009-07-31T20:28:51-04:002009-07-31T20:28:51-04:00Rob Wilkersonhttp://robwilkerson.org
<p>Thanks, Miles. Obviously a nuance with huge implications (if such a thing can still be called a “nuance”). I’ll adjust my code – and the article – immediately. I appreciate the insight.</p> Learning CakePHP: Validationtag:robwilkerson.org,2009-07-31:/id/176//comment_110532009-07-31T17:59:38-04:002009-07-31T17:59:38-04:00Miles Johnsonhttp://milesj.me/
<p>Great article, but one big problem in your code.</p>
<p>return !$this->validates() ? $this->invalidFields() : array();</p>
<p>Should be changed to:</p>
<p>return !$this->validates() ? $this->validationErrors : array();</p>
<p>Because if you use invalidFields(), it calls validates() <span class="caps">AGAIN</span>, which makes it validate <span class="caps">TWICE</span> which causes unnecessary processing and unexpected results.</p>