Saturday, January 7, 2012

Change delete($id) function to delete from a non-primary key.

My delete function (below) is getting the right info from the
index.ctp but, it is trying to delete using the primary key of
'unique'... I'm sure the work needs to be done in the model, and I
don't want to change the primary key. I want ONLY the delete function
to delete from the field 'period_id' instead of 'unique'.

P.S. If i change the primary key in my model to 'unique', it fixes
this problem, but breaks another. Thanks!
- - - - - -
Here is my StudentsController.php


function delete($id) {
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();
}

if($this->isActionable($id)){
if ($this->Student->delete($id)) {
$this->Session->setFlash('Successfully removed.');
$this->redirect(array('controller' => 'posts', 'action' =>
'index'));
}
} else {
$this->Session->setFlash('You cannot delete that.');
$this->redirect(array('controller' => 'posts', 'action' =>
'index'));
}
}


- - - - - - - - -
Here is my index.ctp


$this->Form->postLink(
'Remove Class',
array('controller' => 'students', 'action'
=> 'delete', $ps['Period']['period_id']),
array('confirm' => 'Are you sure?'));

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate