public function UltimateCronPlugin::cleanForm in Ultimate Cron 7.2
Clean form of empty fallback values.
File
- ./
ultimate_cron.plugin.inc, line 422 - Plugin framework for Ultimate Cron.
Class
- UltimateCronPlugin
- This is the base class for all Ultimate Cron plugins.
Code
public function cleanForm($elements, &$values, $parents) {
if (empty($elements)) {
return;
}
foreach (element_children($elements) as $child) {
if (empty($child) || empty($elements[$child]) || is_numeric($child)) {
continue;
}
// Process children.
$this
->cleanForm($elements[$child], $values, $parents);
// Determine relative parents.
$rel_parents = array_diff($elements[$child]['#parents'], $parents);
$key_exists = NULL;
$value = drupal_array_get_nested_value($values, $rel_parents, $key_exists);
// Unset when applicable.
if (!empty($elements[$child]['#markup'])) {
self::drupal_array_remove_nested_value($values, $rel_parents);
}
elseif ($key_exists && empty($value) && !empty($elements[$child]['#fallback']) && $value !== '0') {
self::drupal_array_remove_nested_value($values, $rel_parents);
}
}
}