If a file's 'list' property is NULL, visibility should be determined by its 'list_default' property. It isn't.
(Optionally, skip directly to the patch below.)

--------
Situation:
Some 'attachment' filefield used to be really simple, so I set the "List field:" property to "disabled".

Later, after uploading many attachments to nodes, I change "List field:" to "enabled", and the "Files listed by default" to True.
Result:

1) in node view, all my attachments are gone! <- bug, and inconsistent with 2
2) on the edit form, the "List" checkbox is checked for all file widgets.
3) ...unless you use an SWFUpload widget: then it's unchecked.

2) is the correct behavior; node display should be adjusted to match this.
(and 3 can be ignored until this is fixed - I'll file a separate issue).

This is the code in filefield_widget_process(), corresponding to 2:

   if (!empty($field['list_field'])) {
    $element['list'] = array(
      '#type' => empty($item['fid']) ? 'hidden' : 'checkbox',
      '#title' => t('List'),
      '#value' => isset($item['list']) && !empty($item['fid']) ? $item['list'] : $field['list_default'],
      '#attributes' => array('class' => 'filefield-list'),
    );
  }
  else {
    $element['list'] = array(
      '#type' => 'hidden',
      '#value' => '1',
    );
  }

The patch copies this logic into filefield_file_listed() - except it returns a boolean value.
Please check whether the test on $file['fid'] is necessary; I have no idea.

CommentFileSizeAuthor
filefield_list-default.patch507 bytesroderik
Members fund testing for the Drupal project. Drupal Association Learn more