Created
May 6, 2012 09:48
-
-
Save lenamuit/2621319 to your computer and use it in GitHub Desktop.
Cakephp: add/edit/delete record
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
function admin_add(){ | |
//TODO: check retype password | |
if (!empty($this->data)){ | |
$this->Product->set($this->data); | |
if ($this->Product->validates()){ | |
if ($this->Product->save($this->data)){ | |
$this->Session->setFlash("Add member successfull"); | |
} | |
else{ | |
$this->Session->setFlash("Add member fail"); | |
} | |
$this->redirect(array('action'=>'index')); | |
}else{ | |
//$this->Session->setFlash(explode(',', $this->Product->invalFields())); | |
} | |
} | |
} | |
function admin_delete($id){ | |
if (isset($id) && !empty($id)){ | |
$this->Product->delete($id); | |
} | |
$this->redirect(array('action'=>'index')); | |
} | |
function admin_edit($id){ | |
$this->Product->id = $id; | |
if (!empty($this->data)){ | |
$this->Product->set($this->data); | |
if ($this->Product->validates()){ | |
if ($this->Product->save($this->data)){ | |
$this->Session->setFlash("Add member successfull"); | |
} | |
else{ | |
$this->Session->setFlash("Add member fail"); | |
} | |
$this->redirect(array('action'=>'index')); | |
}else{ | |
//$this->Session->setFlash(explode(',', $this->Product->invalFields())); | |
} | |
} | |
else{ | |
$this->data = $this->Product->read(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment