Jump to content

CakePHP redirect not working


244863

Recommended Posts

I have the controller below and when I use the edit page the redirect works and takes me to the right page. But when I go through the add page it does not????

 

<?php

class GrievanceTypesController extends GrievanceAppController {

               

                function add() {

                                $this->edit();

                                $this->render('edit');

                }

               

                function edit($id = null) {

                                $this->helpers = am($this->helpers, array('Form'));

                                $grievanceTypeGroupId = $this->params['named']['grievance_type_group_id'];

                                $this->set('grievanceTypeGroupId', $grievanceTypeGroupId);

                                if($this->GrievanceType->GrievanceInitiation->typeHasGrievances($id) == true){

                                                $this->flash(

                                                                sprintf(

                                                                                __('The %s, "%s", can not be edited.', true),

                                                                                $this->_humanisedModelName(),

                                                                                $this->GrievanceType->field('title')

                                                                ),

                                                                array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id'))

                                                );

                                }else{

                                                $this->_edit($id, array('redirect' => array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id'))));

                                }

                }

               

                function delete($id = null) {

                                if($this->GrievanceType->GrievanceInitiation->typeHasGrievances($id) == true){

                                                $this->flash(

                                                                sprintf(

                                                                                __('The %s, "%s", can not be deleted.', true),

                                                                                $this->_humanisedModelName(),

                                                                                $this->GrievanceType->field('title')

                                                                ),

                                                                array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id'))

                                                );

                                }else{

                                                $this->_delete($id, array('redirect' => array('controller' => 'grievance_type_groups', 'action' => 'view', $this->GrievanceType->field('grievance_type_group_id'))));

                                }

                }

}

?>

Link to comment
https://forums.phpfreaks.com/topic/248482-cakephp-redirect-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.