public static function FilefieldSourcesPreRenderCallback::preRender in FileField Sources 8
#pre_render callback: hide sources if a file is currently uploaded.
File
- src/
FilefieldSourcesPreRenderCallback.php, line 20
Class
Namespace
Drupal\filefield_sourcesCode
public static function preRender($element) {
// If we already have a file, we don't want to show the upload controls.
if (!empty($element['#value']['fids'])) {
foreach (Element::children($element) as $key) {
if (!empty($element[$key]['#filefield_source'])) {
$element[$key]['#access'] = FALSE;
}
}
}
return $element;
}