function _file_generic_settings_extensions
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().
1 string reference to '_file_generic_settings_extensions'
- file_field_instance_settings_form in modules/
file/ file.field.inc - Implements hook_field_instance_settings_form().
File
-
modules/
file/ file.field.inc, line 141
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);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.