function _webform_edit_file_extensions_validate in Webform 7.4
Same name and namespace in other branches
- 6.3 components/file.inc \_webform_edit_file_extensions_validate()
- 7.3 components/file.inc \_webform_edit_file_extensions_validate()
A Form API element validate function.
Change the submitted values of the component so that all filtering extensions are saved as a single array.
1 string reference to '_webform_edit_file_extensions_validate'
- _webform_edit_file in components/
file.inc - Implements _webform_edit_component().
File
- components/
file.inc, line 260 - Webform module file component.
Code
function _webform_edit_file_extensions_validate($element, &$form_state) {
// Predefined types.
$extensions = array();
foreach (element_children($element['types']) as $category) {
foreach (array_keys($element['types'][$category]['#value']) as $extension) {
if ($element['types'][$category][$extension]['#value']) {
$extensions[] = $extension;
// "jpeg" is an exception. It is allowed anytime "jpg" is allowed.
if ($extension == 'jpg') {
$extensions[] = 'jpeg';
}
}
}
}
// Additional types.
$additional_extensions = explode(',', $element['addextensions']['#value']);
foreach ($additional_extensions as $extension) {
$clean_extension = drupal_strtolower(trim($extension));
if (!empty($clean_extension) && !in_array($clean_extension, $extensions)) {
$extensions[] = $clean_extension;
}
}
form_set_value($element['types'], $extensions, $form_state);
}