Welcome Guest, Not a member yet? Register   Sign In
form data and redirect: how passing a message?
#1

[eluser]sl3dg3hamm3r[/eluser]
Hey there!

I wanted to hear some opinions about the following issue.

Given I have a product-list and an add-mask, which allows to add further products. The scaffolded controller (is that correct english?) would look something like this:

Code:
function index($mgs = NULL) {
  // Lists the products
  // If $msg, pass it to view which would show it on top
}

function addProduct() {
  // Adds a product
  $this->index('Product xyz was successfully added!');
}

As you can see, I list the product-list after adding a product, showing a handy message that the operation was successful.
As we know, this solution contains the problem of resending post-data after reloading the page. Redirect would solve this problem.

But then I wonder, how would you pass this handy message with a redirect? The only solution I can think of might be a session-var. Or is there a more elegant way?

Sincerely
Sl3dg3
#2

[eluser]Bramme[/eluser]
Check the userguide for "flashdata" Wink
#3

[eluser]sl3dg3hamm3r[/eluser]
*slapOnFront* yes, I read it already before, but forgot, thx Smile




Theme © iAndrew 2016 - Forum software by © MyBB