Created
February 6, 2012 17:18
-
-
Save robwilkerson/1753441 to your computer and use it in GitHub Desktop.
CakePHP edit method example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allows an administrator to create a new user. | |
* | |
* @param uuid id A user id. | |
* @access public | |
*/ | |
public function admin_edit( $id ) { | |
$this->User->id = $id; | |
if( !empty( $this->data ) ) { | |
if( $this->User->save( $this->data ) ) { | |
$this->Session->setFlash( sprintf( __( 'User details were updated successfully.', true ), h( $this->data['User']['first_name'] ) ), null, null, 'success' ); | |
$this->redirect( array( 'action' => 'index', 'admin' => true ) ); | |
} | |
else { | |
$this->Session->setFlash( __( 'There was a problem updating this user\'s details. Please check below for any error details.', true ), null, null, 'validation' ); | |
} | |
} | |
else { | |
$this->data = $this->User->read(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allows an administrator to create a new user. | |
* | |
* @param uuid id A user id. | |
* @access public | |
*/ | |
public function admin_edit( $id ) { | |
$this->User->id = $id; | |
if( !empty( $this->data ) ) { | |
if( $this->User->save( $this->data ) ) { | |
$this->Session->setFlash( sprintf( __( 'User details were updated successfully.', true ), h( $this->data['User']['first_name'] ) ), null, null, 'success' ); | |
$this->redirect( array( 'action' => 'index', 'admin' => true ) ); | |
} | |
else { | |
$this->Session->setFlash( __( 'There was a problem updating this user\'s details. Please check below for any error details.', true ), null, null, 'validation' ); | |
} | |
} | |
else { | |
$this->data = $this->User->read(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment