<?php echo $html->link(__('Delete', true), array('action'=>'delete',
$post['Post']['id']), null, sprintf(__('Are you sure you want to
delete # %s?', true), $post['Post']['id'])); ?>
function delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Posts',
true));
$this->redirect(array('action'=>'index'));
}
if ($this->Post->del($id)) {
$this->Session->setFlash(__('Post deleted', true));
$this->redirect(array('action'=>'index'));
}
}
On Oct 29, 7:23 am, artmyth <[email protected]> wrote:
> Hi,
>
> I just installed cake 1.2.5 - kudos for the easy installation..
>
> I am going through the 1.2 blog tutorialhttp://book.cakephp.org/view/219/Blog
> and have run into an error on step 10.1.11 Deleting Posts..
>
> I receive this error when I click on delete:
>
> ------
> Missing Method in PostsController
>
> Error: The action delete is not defined in controller PostsController
>
> Error: Create PostsController::delete() in file: app/controllers/
> posts_controller.php.
>
> <?php
> class PostsController extends AppController {
>
> var $name = 'Posts';
>
> function delete() {
>
> }
>
> }
>
> ?>
> --------
> My posts_controller.php file looks like this:
>
> ----
> <?php
> class PostsController extends AppController {
> var $name = 'Posts';
> function index() {
> $this->set('posts', $this->Post->find('all'));
>
> }
>
> function view($id = null) {
> $this->Post->id = $id;
> $this->set('post', $this->Post->read());
>
> }
>
> function add() {
> if (!empty($this->data)) {
> if ($this->Post->save($this->data)) {
> $this->Session->setFlash('Your post has been saved.');
> $this->redirect(array('action'=> 'index'));
>
> }
>
> function delete($id) {
> $this->Post->delete($id);
> $this->Session->setFlash('The post with id: '.$id.' has been
> deleted.');
> $this->redirect(array('action'=> 'index'));
> }
> }
> }
> }
> ?>
> -----
>
> So I am hoping I can receive some direction on correcting my code or
> install to proceed with the tutorial.
>
> All the best
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---