You are here

function filefield_sources_field_pre_render in FileField Sources 7

Same name and namespace in other branches
  1. 6 filefield_sources.module \filefield_sources_field_pre_render()

A #pre_render function to hide sources if a file is currently uploaded.

1 string reference to 'filefield_sources_field_pre_render'
filefield_sources_element_info in ./filefield_sources.module
Implements hook_element_info().

File

./filefield_sources.module, line 234
Extend FileField to allow files from multiple sources.

Code

function filefield_sources_field_pre_render($element) {

  // If we already have a file, we don't want to show the upload controls.
  if (!empty($element['#value']['fid'])) {
    foreach (element_children($element) as $key) {
      if (!empty($element[$key]['#filefield_source'])) {
        $element[$key]['#access'] = FALSE;
      }
    }
  }
  return $element;
}