function _file_generic_settings_extensions
_file_generic_settings_extensions($element, &$form_state)
Element validate callback for the allowed file extensions field.
This doubles as a convenience clean-up function and a validation routine. Commas are allowed by the end-user, but ultimately the value will be stored as a space-separated list for compatibility with file_validate_extensions().
File
- modules/file/file.field.inc, line 141
- Field module functionality for the File module.
Code
function _file_generic_settings_extensions($element, &$form_state) { if (!empty($element['#value'])) { $extensions = preg_replace('/([, ]+\.?)/', ' ', trim(strtolower($element['#value']))); $extensions = array_filter(explode(' ', $extensions)); $extensions = implode(' ', array_unique($extensions)); if (!preg_match('/^([a-z0-9]+([.][a-z0-9])* ?)+$/', $extensions)) { form_error($element, t('The list of allowed extensions is not valid, be sure to exclude leading dots and to separate extensions with a comma or space.')); } else { form_set_value($element, $extensions, $form_state); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!file!file.field.inc/function/_file_generic_settings_extensions/7.x