function _prepopulate_request_walk in Prepopulate 6.2
Same name and namespace in other branches
- 7.2 prepopulate.module \_prepopulate_request_walk()
Internal helper to set element values from the $_REQUEST variable.
Parameters
&$form: Array. A form element.
&$requestslice: String or array. Value(s) to be applied to the element.
1 call to _prepopulate_request_walk()
- prepopulate_after_build in ./
prepopulate.module - An #after_build function to set the values prepopulated in the request.
File
- ./
prepopulate.module, line 58 - Fill form elements with data from GET or POST values.
Code
function _prepopulate_request_walk(&$form, &$requestslice) {
$limited_types = array(
'value',
'hidden',
'button',
'image_button',
);
if (is_array($requestslice)) {
foreach (array_keys($requestslice) as $requestvar) {
if (element_child($requestvar) && !is_null($form[$requestvar]) && !in_array($form[$requestvar]['#type'], $limited_types)) {
if (!isset($form[$requestvar]['#access']) || $form[$requestvar]['#access'] != FALSE) {
_prepopulate_request_walk($form[$requestvar], $requestslice[$requestvar]);
}
}
}
if (!empty($form['#default_value']) && is_array($form['#default_value'])) {
$form['#default_value'] = array_merge($form['#default_value'], $requestslice);
}
}
else {
if ($form['#type'] == 'markup' || empty($form['#type'])) {
$form['#value'] = check_plain($requestslice);
}
else {
$form['#value'] = $requestslice;
}
}
}