Your controllers should normally extend InvController, which provides a few basic methods for dealing with user input and generating output.
setInputValues() runs very early on in any controller invocation, and is used to setup user input which will be used by the controller later on. During the normal course of events, this will consist of fetching values passed into the controller in GET or POST:
$this->setInputValue([paramname]);
Each time you call the method above, it will set properties in the $this->arr_input array: so the above will set $this->arr_input(paramname). If the user has posted in a value for paramname in either the GET or POST input, this will be stored in the value, if not, this will be set to false.
This deals with all the tedious business of needing to check isset() on all your user input before evaluating it! In the procedural part of the controller, you can now simply do:
if($this->arr_input[paramname]){ continue } else { error }
For example:
$this->setInputValue('firstname'); $this->setInputValue('surname'); $this->setInputValue('email');
Will set up the following
$this->arr_input['firstname']; $this->arr_input['surname']; $this->arr_input['email'];
The controller also has an array called $this->arr_user_input - this is /all/ of the GET and POST input, unfiltered, whether it has been "imported" into the controller using the $this->setInputValue() method or not. You shouldn't normally need to access this array, but sometimes it is useful to be able to deal with raw user input in different ways, so the data is there should you need it. Under normal circumstances, you should use $this->setInputValue(paramname); and $this->arr_input(paramname)
If the input is a search / filter parameter for a list view, you may wish to preserve its value if the user hits a pagination link. to do this use $this->setListFilterInputValue([paramname]) instead of $this->setInputValue([paramname])
$this->setListFilterInputValue('search');
$this->setNumericInputValue('varname' , [$decimal_places]);
Validates input as a number and returns the numeric value. If not set, $decimal places will default to -1 (auto).
Passing a flag to either of the above methods adds the input to a per-window session.
$this->setInputValue('firstname' , 1); $this->setNumericInputValue('varname' , $decimal_places , 1);
A unique window session id (wsid=) will be added to the hidden token fields and tokenised links, and the previous inputs will then be retrieved back into user input on subsequent pages, available to be imported from $this->arr_user_input using the usual $this->setInputValue() and $this->setNumericInputValue() methods as with any other user input. This will allow you to manage input on multi-stage forms without needing to do anything other than flag the inputs initially as above.
Once you are done with the window session input, you can destroy it with:
$this->resetWindowSession();