Friday, February 27, 2009

Check for empty fields and redirect

Hi

I have users and profiles tables and when a new member registers the
profile table gets partially populated i.e. firstname, surname, email
address. After account activation the member logs in for the first
time. I want to redirect them to the profile home (edit action) to
complete the form. I then have validation which will force certain
fields to be complete before the user goes any further. The easiest
way i've found to do this is redirect to profile home and immediately
save the data, if valid it then redirects to the members area, else
the member recieves the appropriate validation flash messages. This
method fits my purpose with minimum effort, but it's not idea to save
each time users are logging in. Can anyone give me advice on the best
way to go forward with this?

Ross

profile_controller.php

function edit(){
....
if (empty($this->data)) {
$this->data = $this->Profile->read(null, $this->Auth->User('id'));
if($this->Profile->save($this->data)) {
$this->redirect(array('controller'=>'improvements',
'action'=>'index'));
}
}
.....
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

No comments: