Solved

CakePHP setFlash - Can it pass a variable to view?

Posted on 2011-09-25
1
330 Views
Last Modified: 2012-05-12
Beneath is the code I'm using.  I'd like to offer the user the ability to restore the id of whatever it is they just deleted.  In order to do that I need to pass the id back to the view file:
	function admin_delete($id = null) {
		if ( !$id ) {
			$this->Session->setFlash('Invalid event', true);
			$this->redirect(array('action' => 'index'));
		}
		if ($this->Event->softDelete( $id )) {
			$this->Session->setFlash( 'Event deleted', true , array( 'restoreID' => $id ) );
			$this->redirect( array( 'action' => 'index' ) );
		}
	}

Open in new window

0
Comment
Question by:radarhill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
radarhill earned 0 total points
ID: 36596877
Found a way to make this happen myself:
		if ($this->Event->softDelete( $id )) {
			$this->Session->setFlash( 'Event deleted', true );
			$this->redirect( array( 'action' => 'index/restoreID:'.$id ) );
		}

Open in new window

0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question