Your redirect is within the block "if($this->Attraction->delete($id))" but
if you recall you return false in beforeDelete to cancel the operation
meaning the controller thinks the delete has failed.

Try this:

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

    $this->Attraction->id = $id;

    if ($this->Attraction->delete($id)) {
        $this->Session->setFlash(__('De attractie met id %s werd succesvol
verwijderd.', h($id)), 'default', array(
            'class' => 'alert alert-success'
        ));
    }

    return $this->redirect(array(
        'action' => 'index'
    ));
}


On 27 July 2014 10:24, Sam Clauw <i...@bellewaerdefun.be> wrote:

> Well, the weird thing is that's how I originally wrote it, and that won't
> work. An illustration of how it all looks right now:
>
> *Controller (AttractionsController.php)*
>
> public function delete($id)
> {
>     if ($this->request->is('get')) {
>         throw new MethodNotAllowedException();
>     }
>
>     $this->Attraction->id = $id;
>
>     if ($this->Attraction->delete($id)) {
>         $this->Session->setFlash(__('De attractie met id %s werd succesvol
> verwijderd.', h($id)), 'default', array(
>             'class' => 'alert alert-success'
>         ));
>
>         return $this->redirect(array(
>             'action' => 'index'
>         ));
>     }
> }
>
> *AppModel*
>
> class AppModel extends Model {
>
>     // soft delete functionality
>
>     public function beforeDelete()
>     {
>         if ($this->hasField('deleted')) {
>             if ($this->saveField('deleted', date('Y-m-d H:i:s'))) {
>                 return false;
>             }
>         }
>     }
> }
>
> I'm still getting the error:
>
> Missing View
>>
>> *Error: *The view for *AttractionsController::**delete()* was not found.
>> *Error: *Confirm you have created the file:
>> D:\Websites\BellewaerdeFun\app\Plugin\CoasterCms\View\Attractions\delete.ctp
>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Kind Regards
 Stephen Speakman

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to