I want the users of my application to be able to change only certain
aspects of their profile. Limiting the fields in the save method
prevents users from modifying fields like registration date or
username. My problem is: If there are validation errors these "read-
only" properties of the model disappear.
Closly following the blog tutorial the edit method of my controller
looks something like this:

function edit ($id = null) {
  if (!empty($this->data)) {
    if ($this->User->save($this->data['User'], true, array('email',
'date_expires'))) {
      $this->redirect('/users/index');
    }
  } else {
    $this->User->id = $id;
    $this->data = $this->User->read();
  }
}

In the corresponding edit.thtml I want to show the username as
headline like this
<h2>User <?php echo $this->data['User']['username']; ?></h2>

When the validation fails the username is undefined, I assume because
it is not a part of the $_POST'ed data. Keeping the read-only
properties within a session or hidden fields may be possible but seems
like an hack to me. I guess I'm missing the obvious way of doing this.

I would be very glad if anyone could point me to a solution. Thank you
very much in advance.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to