Re: Validation (Check If username Exists Display Error Message)
Thanks Solved. But I have a question, with that said, 1.3 version and
the newer--it all seem much easier than the older version, seems like
less codes required...
Or is it I'm missing something ?
All I have to do is just add in the additional array into my existing
username validation array instead of creating a new function called
beforeValidate(). Am I right ?
Just to ensure because I'm quite new to this and I'm programming
challenged. This will help to clarify my upcoming tasks.
On Dec 18, 2:48 am, Stefano Salvatori <ssalvat...@gmail.com> wrote:
> cakephp 1.3 has isUnique
>
> http://book.cakephp.org/view/134/Core-Validation-Rules#isUnique-472
>
>
>
> On Fri, Dec 17, 2010 at 2:19 PM, John Maxim <goog...@gmail.com> wrote:
> > Hi everyone,
>
> > I have a problem with validation script here:
>
> > *******The first script I used*********
>
> > function beforeValidate() {
> > if (!$this->id) {
> > if ($this->findCount(array('User.username'
> > => $this->data['User']['username'])) > 0) {
> > $this->invalidate('username_unique');
> > return false;
> > }
> > }
> > return true;
> > }
>
> > *******The second script I used*********
>
> > function beforeValidate() {
> > if (!$this->id) {
> > if ($this->find('count',array('conditions' =>array('User.username' =>
>
> > $this->data))) > 0) {
> > $this->invalidate('username_unique');
> > return false;
> > }
> > }
> > return true;
> > }
>
> > ***
> > Error I get:
> > Warning (512): SQL Error: 1062: Duplicate entry 'James5' for key
> > 'username' [CORE\cake\libs\model\datasources\dbo_source.php, line 684]
>
> > ***
>
> > It was supposed to display the error msg stating the username already
> > taken. I don't know where went wrong... Anyone can shed some light
> > here ?
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with their CakePHP related questions.
>
> > You received this message because you are subscribed to the Google Groups "CakePHP" group.
> > To post to this group, send email to cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
>
> --
> Stefano Salvatori M.http://stefano.salvatori.cl/
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home