glFusion Wiki

Site Tools


glfusion:development:api:sanitize_class:buttoncheck

sanitize::buttonCheck

(glFusion SVN)

buttonCheck - Find which button was pressed on form.

Description

buttonCheck($buttonList, $A, $default, $return_name)

Find which button was pressed on form.

Parameters

buttonList

List of buttons

A

Array such as $_GET, $_POST, $_COOKIE or $_REQUEST

default

If no entry is in the array, return this default value.

return_name

If true, the returned name is the name in the buttonlist.
The default is TRUE, return the name of the button from the buttonList.
Set this to FALSE to return the value of the button.

Return Value

The given button or the associated key of the button.

Example

Instead of doing this:
  <input type="submit" value="{lang_save}" name="mode">
  <input type="submit" value="{lang_cancel}" name="mode">

and checking
  if ($_POST['mode'] == $LANG_ADMIN['save']) ...

Do this:
  <input type="submit" value="{lang_save}" name="save">
  <input type="submit" value="{lang_cancel}" name="cancel">

and check this way:
  $mode = $inputHandler->buttonCheck(array('save','cancel'), $_POST, '');
  if ($mode == 'save') ...

Notes

See Also

glfusion/development/api/sanitize_class/buttoncheck.txt · Last modified: 2017/04/12 21:15 (external edit)

Page Tools