Oh but the extra code is for extra form validation on my end. Using
invalidate() adds errors to the array that I can then loop through and
display in the view (I dislike having the error show up after the
input).

On Dec 17, 3:24 am, AD7six <andydawso...@gmail.com> wrote:
> On Dec 17, 9:56 am, gearvOsh <mileswjohn...@gmail.com> wrote:
>
> > Nope, still doesn't work. This seems like a lot of hassle/steps in
> > between just to do something simple like update.
>
> That's a lot of fat controller code for something as simple as that
> too ;). e.g. You should almost never need to do this in a controller
> "$this->User->invalidate..".
>
> Of the snippet you pasted, your controller code should be *no more*
> than
>
> function xyz($a, $param) {
> if ($this->data) {
> ..
> if ($this->User->save($data, extra, params)) {
>  $this->Session->setFlash('success');
>  $this->redirect('/wherever');
>
> }
> ..
> }
>
> AD
>
>
>
> > Heres a snippet of my code:
>
> > if ($this->User->validates()) {
> >     $userObj = $this->User->find('first', array(
> >         'conditions' => array(
> >             'User.username' => $this->data['User']['username'],
> >             'User.password' => $this->data['User']['password'],
> >             'User.hash' => $hash
> >         ),
> >         'fields' => array('User.id', 'User.signupDate')
> >     ));
>
> >     if (!empty($userObj)) {
> >         $this->User->create();
> >         $this->User->id = $userObj['User']['id'];
>
> >         if ($this->User->verifyEmail($userObj['User']['signupDate'],
> > $this->Settings->grab('email_verify_exp_hours'))) {
> >             $this->User->saveField('status', 'active');
> >         } else {
> >             $this->User->invalidate('', sprintf(__d('errors',
> > 'verifyTimeElapsed', true), $this->Settings->grab
> > ('email_verify_exp_hours')));
> >             $this->User->saveField('status', 'inactive');
> >         }
> >     } else {
> >         $this->User->invalidate('', __d('errors', 'verifyFailure',
> > true));
> >     }
>
> > }
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to