| 1 |
<?php |
<?php |
| 2 |
// $Id: prepopulate.module,v 1.10 2008/05/03 18:04:54 add1sun Exp $ |
// $Id: prepopulate.module,v 1.11 2008/06/23 14:50:42 add1sun Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 42 |
* @param &$getslice |
* @param &$getslice |
| 43 |
* String or array. Value(s) to be applied to the element. |
* String or array. Value(s) to be applied to the element. |
| 44 |
*/ |
*/ |
| 45 |
function _prepopulate_get_walk(&$form, &$getslice) { |
function _prepopulate_get_walk( & $form, & $getslice) { |
| 46 |
if (!is_array($getslice)) { |
if (is_array($getslice)) { |
| 47 |
$form['#default_value'] = $getslice; |
if (!is_null($form['#default_value'])) { |
| 48 |
} |
if (!is_array($form['#default_value'])) { |
| 49 |
else { |
// Something went wrong so stop here. |
| 50 |
foreach (array_keys($getslice) as $getvar) { |
return; |
| 51 |
if (element_child($getvar) && is_array($form) && !is_null($form[$getvar])) { |
} |
| 52 |
_prepopulate_get_walk($form[$getvar], $getslice[$getvar]); |
$form['#default_value'] = array_merge($form['#default_value'], $getslice); |
| 53 |
|
} |
| 54 |
|
else { |
| 55 |
|
foreach (array_keys($getslice) as $getvar) { |
| 56 |
|
if (element_child($getvar) && is_array($form) && !is_null($form[$getvar])) { |
| 57 |
|
_prepopulate_get_walk($form[$getvar], $getslice[$getvar]); |
| 58 |
|
} |
| 59 |
} |
} |
| 60 |
} |
} |
| 61 |
} |
} |
| 62 |
|
else { |
| 63 |
|
$form['#default_value'] = $getslice; |
| 64 |
|
} |
| 65 |
} |
} |