public function CronPlugin::cleanForm in Ultimate Cron 8.2
Clean form of empty fallback values.
File
- src/
CronPlugin.php, line 179
Class
- CronPlugin
- This is the base class for all Ultimate Cron plugins.
Namespace
Drupal\ultimate_cronCode
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'])) {
static::drupal_array_remove_nested_value($values, $rel_parents);
}
elseif ($key_exists && empty($value) && !empty($elements[$child]['#fallback']) && $value !== '0') {
static::drupal_array_remove_nested_value($values, $rel_parents);
}
}
}