diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index 319cd58..e7b2a6b 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -23,6 +23,7 @@ function file_field_info() { 'file_directory' => '', 'max_filesize' => '', 'description_field' => 0, + 'description_field_default' => '', ), 'default_widget' => 'file_generic', 'default_formatter' => 'file_default', @@ -116,6 +117,19 @@ function file_field_instance_settings_form($field, $instance) { '#weight' => 11, ); + $form['description_field_default'] = array( + '#type' => 'textfield', + '#title' => t('Default file description'), + '#default_value' => isset($settings['description_field_default']) ? $settings['description_field_default']: '', + '#size' => 60, + '#weight' => 12, + '#states' => array( + 'visible' => array( + ':input[name="instance[settings][description_field]"]' => array('checked' => TRUE), + ), + ), + ); + return $form; } @@ -595,7 +609,7 @@ function file_field_widget_value($element, $input = FALSE, $form_state) { $return += array( 'fid' => 0, 'display' => 1, - 'description' => '', + 'description' => '#DESCRIPTION', ); return $return; @@ -634,10 +648,14 @@ function file_field_widget_process($element, &$form_state, $form) { // Add the description field if enabled. if (!empty($instance['settings']['description_field']) && $item['fid']) { + $description_value = isset($item['description']) ? $item['description'] : ''; + if ($description_value == '#DESCRIPTION') { + $description_value = isset($instance['settings']['description_field_default']) ? $instance['settings']['description_field_default'] : ''; + } $element['description'] = array( '#type' => variable_get('file_description_type', 'textfield'), '#title' => t('Description'), - '#value' => isset($item['description']) ? $item['description'] : '', + '#value' => $description_value, '#maxlength' => variable_get('file_description_length', 128), '#description' => t('The description may be used as the label of the link to the file.'), );