• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URI change when calling controller functions

#1
[eluser]Bondergaard[/eluser]
Hi
I have a form with several submit buttons for different actions. The way I handle that is that I have a function in my controller that checks the submit button value and call the appropriate function in the controller. It works fine, but when I submit the form the url is index.php/controller/handler and I want it to be index.php/controller/functionA if the first submit button is clicked and so on. I know that I can do it with a redirect, but then all the post variables from the form is not passed to it. Is there a way to do that?

The code below is just an example.

Form:
Code:
<form action="controller/handler" method="POST">
<input type="hidden" name="beverage" value="water" />
<input type="submit" name="formAction" value="a" />
<input type="submit" name="formAction" value="b" />
</form>

Controller:
Code:
function handler()
{
$action = $this->input->post('formAction');

if($action == 'a')
  $this->functionA(); //Works but url is still controller/handler
  redirect('controller/functionA'); //URL is correct but the post variable is not passed
if($action == 'b')
  $this->functionB();
}

functionA()
{
  echo $this->input->post('beverage');
}

functionB()
{
  echo $this->input->post('beverage');
}


Messages In This Thread
URI change when calling controller functions - by El Forum - 05-04-2011, 03:59 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 04:09 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 04:29 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 04:36 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 04:51 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 04:58 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 05:17 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 05:21 AM
URI change when calling controller functions - by El Forum - 05-04-2011, 06:08 AM
URI change when calling controller functions - by El Forum - 07-31-2011, 10:24 AM
URI change when calling controller functions - by El Forum - 07-31-2011, 01:07 PM
URI change when calling controller functions - by El Forum - 07-31-2011, 05:41 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.