URI change when calling controller functions |
[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"> Controller: Code: function handler()
[eluser]Sudz[/eluser]
You have to load your view file in the funtion below Code: functionA() If you can post your code then it is easy to rectify.
[eluser]Bondergaard[/eluser]
That is not really my issue, the issue is the url which when clicking button is index.php/controller/handler and not index.php/controller/functionA. I've updated the code in the first post to clarify what happens.
[eluser]Sudz[/eluser]
Issue your are facing is not an issue dude. it is going to happen because when you calling functionA after executing statements in functionA, control returns from functionA to function handler. And from where you are going to load your form view? URI only changes when you load the view.
[eluser]Bondergaard[/eluser]
I know that it is going to happen, I'm asking if there is an other way to do it. In other words can I call the redirect() function and pass some post variables to it in some way, or do something similar.
[eluser]Bondergaard[/eluser]
I don't know if you really understand my question but it does not sound like what I want to do is possible. The only way to do it, is to use javascript to change the form action to index.php/controller/functionA or index.php/controller/functionB before submitting it. I just wanted to see if there was a way to avoid that. Anyway, thanks for your help
[eluser]Sudz[/eluser]
Try this man Code: functionA()
[eluser]Bondergaard[/eluser]
That doesn't make a difference. It doesn't change the url which is what I want to do..
[eluser]blindrc[/eluser]
Not sure if this will help, but "remapping" might be the solution to your problem. Check out the following article: http://thenerdary.net/articles/entry/codeigniter_remapd |
Welcome Guest, Not a member yet? Register Sign In |