mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 17:24:46 +02:00
Add support for multi-dimensional arrays in $input with a $config->wireInputArrayDepth setting. This was requested in prior feature requests and in PR #161 but ended up writing it in a different way than the PR to allow for control over the allowed max dimension and consistency with multidimensional arrays in $_GET or $_POST. To enable multi-dimensional array support add $config->wireInputArrayDepth = 2; to /site/config.php and use a value of 2 (or higher) to indicate the number of dimensions you want to support.
Co-authored-by: porl <porl42@gmail.com>
This commit is contained in:
@@ -1031,6 +1031,26 @@ $config->wireInputOrder = 'get post';
|
||||
*/
|
||||
$config->wireInputLazy = false;
|
||||
|
||||
/**
|
||||
* Maximum depth for input variables accessed from $input
|
||||
*
|
||||
* A value of 1 (or less) means only single dimensional arrays are allowed. For instance, `$a['foo']`
|
||||
* would be allowed (since it is one dimension), but `$a['foo']['bar']` would not because it is
|
||||
* multi-dimensional to a depth of 2.
|
||||
*
|
||||
* A value of 2 or higher enables multi-dimensional arrays to that depth. For instance, a value of 2
|
||||
* would allow `$a['foo']['bar']` and a value of 3 or higher would enable `$a['foo']['bar']['baz']`.
|
||||
*
|
||||
* Note: if your use case requires multi-dimensional input arrays and you do not have control over
|
||||
* this setting (like if you are a 3rd party module author), or are using a version of PW prior to
|
||||
* 3.0.178 you can always still access multi-dimensional arrays directly from `$_GET` or `$_POST`.
|
||||
*
|
||||
* @var int
|
||||
* @since 3.0.178
|
||||
*
|
||||
*/
|
||||
$config->wireInputArrayDepth = 1;
|
||||
|
||||
/**
|
||||
* Options for setting cookies from $input->cookie()->set(...)
|
||||
*
|
||||
|
Reference in New Issue
Block a user