summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Haug2010-06-29 21:38:10 (GMT)
committer Nathan Haug2010-06-29 21:38:10 (GMT)
commit3fdeaa24f9703ff4c6d0176b8983e7536be5aca5 (patch)
tree37e3e3f8659fe4fa9b72e74fb624c26296bf7f12
parent7d1bd72d28de5d7e144f07582d3aa946ecdbe44c (diff)
#834946: Commas in extension list breaks content_copy exports.
-rw-r--r--filefield_widget.inc13
1 files changed, 12 insertions, 1 deletions
diff --git a/filefield_widget.inc b/filefield_widget.inc
index 0bb4f73..9976b23 100644
--- a/filefield_widget.inc
+++ b/filefield_widget.inc
@@ -17,7 +17,6 @@ function filefield_widget_settings_form($widget) {
// Convert the extensions list to be a human-friendly comma-separated list.
$extensions = is_string($widget['file_extensions']) ? $widget['file_extensions'] : 'txt';
- $extensions = implode(', ', explode(' ', $extensions));
$form['file_extensions'] = array(
'#type' => 'textfield',
'#title' => t('Permitted upload file extensions'),
@@ -26,6 +25,7 @@ function filefield_widget_settings_form($widget) {
'#maxlength' => 512,
'#description' => t('Extensions a user can upload to this field. Separate extensions with a space and do not include the leading dot. Leaving this blank will allow users to upload a file with any extension.'),
'#element_validate' => array('_filefield_widget_settings_extensions_validate'),
+ '#pre_render' => array('_filefield_widget_settings_extensions_value'),
'#weight' => 1,
);
@@ -95,6 +95,17 @@ function filefield_widget_settings_save($widget) {
return array('file_extensions', 'file_path', 'progress_indicator', 'max_filesize_per_file', 'max_filesize_per_node');
}
+/**
+ * A FAPI #pre_render() function to set a cosmetic default value for extensions.
+ */
+function _filefield_widget_settings_extensions_value($element) {
+ $element['#value'] = implode(', ', explode(' ', $element['#value']));
+ return $element;
+}
+
+/**
+ * A FAPI #element_validate callback to strip commas from extension lists.
+ */
function _filefield_widget_settings_extensions_validate($element, &$form_state) {
// Remove commas from file extensions.
$value = str_replace(',', ' ', $element['#value']);