function _feedapi_populate in FeedAPI 6
Same name and namespace in other branches
- 5 feedapi.module \_feedapi_populate()
Set default value of $form elements if present in $settings.
1 call to _feedapi_populate()
- feedapi_form_alter in ./
feedapi.module - Implementation of hook_form_alter().
File
- ./
feedapi.module, line 1463 - Handle the submodules (for feed and item processing) Provide a basic management of feeds
Code
function _feedapi_populate($form, $settings) {
foreach ($form as $k => $v) {
if (is_array($v)) {
if (array_key_exists('#default_value', $v)) {
// Don't prepopulate feedapi_url slot, not stored in settings
// Might be overwritten otherwise by users without advanced feedapi options permissions.
// Todo: stick all settings form elements that are not in 'parsers' or 'processors' in 'general' -
// This is kind of tricky though without breaking sites out there.
if ($k != 'feedapi_url') {
if (isset($form[$k]['#parents']) && is_array($form[$k]['#parents'])) {
// respect #parents if set
$form[$k]['#default_value'] = _feedapi_populate_get_setting($form[$k]['#parents'], $settings);
}
elseif (isset($settings[$k])) {
$form[$k]['#default_value'] = $settings[$k];
}
}
}
elseif (isset($settings[$k])) {
$form[$k] = _feedapi_populate($form[$k], $settings[$k]);
}
}
}
return $form;
}