$input->whitelist() method

Get or set a whitelist variable

Whitelist variables are used by modules and templates and assumed to be sanitized. Only place variables in the whitelist that you have already sanitized.

The whitelist is a list of variables specifically set by the application as sanitized for use elsewhere in the application. This whitelist is not specifically used by ProcessWire unless you populate it from your templates or the API. When populated, it is used by the MarkupPagerNav module (for instance) to ensure that sanitized query string (GET) variables are maintained across paginations.

Examples

// Retrieve a GET variable, sanitize/validate it, and populate to whitelist
$limit = (int) $input->get('limit');
if($limit < 10 || $limit > 100) $limit = 25; // validate
$input->whitelist('limit', $limit); 
// Retrieve a variable from the whitelist
$limit = $input->whitelist('limit'); 

Usage

// basic usage
$mixed = $input->whitelist();

// usage with all arguments
$mixed = $input->whitelist(string $key = '', mixed $value = null);

Arguments

NameType(s)Description
key (optional)string

Whitelist variable name that you want to get or set.

  • If $key is blank, it assumes you are asking to return the entire whitelist.
  • If $key and $value are populated, it adds the value to the whitelist.
  • If $key is an array, it adds all the values present in the array to the whitelist.
  • If $value is omitted, it assumes you are asking for a value with $key, in which case it returns it.
value (optional)mixed

Value you want to set (if setting a value). See explanation for the $key param.

Return value

null mixed WireInputData

Returns whitelist variable value if getting a value (null if it doesn't exist).


$input methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #549
    In the 549th issue of ProcessWire Weekly we’re going to check out the latest core updates, highlight one older yet still very relevant third party module, and more. Read on!
    Weekly.pw / 17 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH