getdata
- Ariadne >
- Library >
- Ariadne 2.2 >
- Manuals >
- Programmers Reference >
- Classes >
- Object >
- PINP Methods >
(mixed) getdata($varname, $nls=" none")
Returns form data or object data associated with the given variable and language.
| Argument | Description |
|---|---|
| (string) $varname | The name of the variable to return. |
| (string) $nls | The language code of the variable, or
'none'. |
getdata() searches through submitted form
data, post method first, then get, for variables with
the given name and language. If the variable is not found in the
submitted form data, getdata will return the variable as defined in the current
object. If no such variable is defined there, it will return false. In no other
case will it return a boolean value.
getdata() knows how the Ariadne wizards store data, and will
search that too, just as it will search the internal Ariadne variable store,
where putvar() stores its data.
The search order is:
| Location | Description |
|---|---|
| $arCallArgs | The arguments passed to the current template. |
| $ARCurrent | The Ariadne variable store, as used by
putvar() |
| $_POST | Submitted form data using the post
method. |
| $_GET | Submitted form data using the get
method. |
| $arStoreVars | The wizard variable store. |
| $data | The current objects data. |
Because getdata() always checks the current object as well, you must alter a form slightly for some form input fields, or otherwise you won't be able to clear these fields. If you have a list of checkboxes, always make sure to add a hidden input field with a value that is used when no checkbox associated with a single name is checked. The same goes for multiple select lists.
The reason for this is that the browser will not transmit any data for checkboxes that aren't checked. So if in a list of checkboxes none is checked, getdata will not find any data in the form, and will default to the data already in the object. Without altering the form, your template cannot distinguish between these cases.
The solution is very simple:
<form>
<input type="hidden" name="mychecks[0]" value="false">
check one: <input type="checkbox"
name="mychecks[1]" value="1"><br>
check two: <input type="checkbox"
name="mychecks[2]" value="2"><br>
<input type="submit" name="ok" value="Ok">
</form>
In this case the form will always submit at least one value for the
mychecks array, which allows the user to clear out the
rest.

