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

#11
[eluser]byde[/eluser]
have you try javascript?

Code:
<form action="controller/handler" method="POST">
<input type="hidden" name="beverage" value="water" />
<input type="submit" name="formAction" o nclic k="this.form.action = 'controller/functionA';" value="a" />
<input type="submit" name="formAction" o nclic k="this.form.action = 'controller/functionB';" value="b" />
</form>

#12
[eluser]Aken[/eluser]
You could use the controller set up as you have shown, and use a method parameter to flag whether or not information should be output, or a redirect to the function page should be used.
Code:
function handler()
{
    if ($action == 'a')
    {
        $this->functionA(true);
    }
}

function functionA($redirect = false)
{
    ...

    if ($redirect === true)
    {
        // Redirect to functionA page.
    } else {
        // Load view
    }
}

You could also use Javascript to change the form's action page based on the button that was called.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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