function _allow_all_file_extensions_fix_validator in Allow All File Extensions 7
This ugly little hack of a function recursively crawls through the form and adds an empty file_validate_extensions array to every managed_file element that doesn't already contain one. I shouldn't have had to do it this way, but unfortunately Drupal 7's smarter-than-you file extension validation code is added while the form is being generated, so there's really no other way.
1 call to _allow_all_file_extensions_fix_validator()
- allow_all_file_extensions_form_alter in ./
allow_all_file_extensions.module - Implements hook_form_alter().
File
- ./
allow_all_file_extensions.module, line 29
Code
function _allow_all_file_extensions_fix_validator(&$element) {
if (isset($element)) {
if (isset($element['#type']) && ($element['#type'] === 'managed_file' || $element['#type'] === 'mfw_managed_file')) {
if (!isset($element['#upload_validators']['file_validate_extensions'])) {
$element['#upload_validators']['file_validate_extensions'] = array();
}
}
$children = element_children($element);
if (is_array($children)) {
foreach ($children as $child) {
_allow_all_file_extensions_fix_validator($element[$child]);
}
}
}
}