function gdpr_tasks_email_settings_validate in General Data Protection Regulation 7
Validation handler for gdpr_tasks_email_settings().
1 string reference to 'gdpr_tasks_email_settings_validate'
- gdpr_tasks_email_settings in modules/
gdpr_tasks/ gdpr_tasks.admin.inc - Config form for automated emails for task requests.
File
- modules/
gdpr_tasks/ gdpr_tasks.admin.inc, line 311 - Administrative page and form callbacks for the GDPR Tasks module.
Code
function gdpr_tasks_email_settings_validate(&$form, &$form_state) {
foreach (element_children($form['gdpr_tasks_emails']) as $key) {
// Skip our vertical tabs.
if ($key == 'emails') {
continue;
}
$element = $form['gdpr_tasks_emails'][$key];
// If enabled, check we have our required values.
$enabled = drupal_array_get_nested_value($form_state['values'], $element['enabled']['#parents']);
if (!empty($enabled) && !empty($element['enabled']['#gdpr_tasks_email_dependents'])) {
foreach ($element['enabled']['#gdpr_tasks_email_dependents'] as $array_parents) {
// Get hold of the sub element we are requiring.
$sub_element = drupal_array_get_nested_value($element, $array_parents);
if (!$sub_element) {
continue;
}
// Get hold of it's value and check it. Show an error if it's empty.
$value = drupal_array_get_nested_value($form_state['values'], $sub_element['#parents']);
if (empty($value)) {
$error = t('%title is required if %set is enabled.', array(
'%title' => $sub_element['#title'],
'%set' => $element['#title'],
));
form_error($sub_element, $error);
}
}
}
}
}