Welcome Guest, Not a member yet? Register   Sign In
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.




Theme © iAndrew 2016 - Forum software by © MyBB