Welcome Guest, Not a member yet? Register   Sign In
calling controller functions
#1

[eluser]edhrx[/eluser]
hi,
Is this 'legitimate' code

I have a controller with these functions

function listall($clientid = "")

function save()

listall just just shows a list of stuff. If the $clientid is "" then it gets the clientid from a $this->input->post. The user eventually edits a record and saves the form which uses controllername/save. Works ok.

Is it acceptable (it works) to call the listall function from the save function passing in the clientid variable... should I be using a redirect



Ed.
#2

[eluser]Pascal Kriete[/eluser]
It's perfectly acceptable, but may not be the best idea. The two things I always try to think about are ease of use and flexibility. In this case, those two lead me to say a redirect is better.

1. If a user refreshes they send the data again, and thus may end up at a different page, or create duplicate entries.
2. The page can't be bookmarked, which can be frustrating for the user.
3. If you ever decide to display a success message in a future version, a redirect will tie in nicely with flashdata and create almost no work for you.

That doesn't mean you shouldn't use it though. It depends on the situation. I personally use this a lot in my index functions, since those are usually just like another function with a default parameter.




Theme © iAndrew 2016 - Forum software by © MyBB