public static function FileUploadForm::hideExtraSourceFieldComponents in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media_library/src/Form/FileUploadForm.php \Drupal\media_library\Form\FileUploadForm::hideExtraSourceFieldComponents()
Processes an image or file source field element.
Parameters
array $element: The entity form source field element.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
$form: The complete form.
Return value
array The processed form element.
File
- core/
modules/ media_library/ src/ Form/ FileUploadForm.php, line 268
Class
- FileUploadForm
- Creates a form to create media entities from uploaded files.
Namespace
Drupal\media_library\FormCode
public static function hideExtraSourceFieldComponents($element, FormStateInterface $form_state, $form) {
// Remove original button added by ManagedFile::processManagedFile().
if (!empty($element['remove_button'])) {
$element['remove_button']['#access'] = FALSE;
}
// Remove preview added by ImageWidget::process().
if (!empty($element['preview'])) {
$element['preview']['#access'] = FALSE;
}
$element['#title_display'] = 'none';
$element['#description_display'] = 'none';
// Remove the filename display.
foreach ($element['#files'] as $file) {
$element['file_' . $file
->id()]['filename']['#access'] = FALSE;
}
return $element;
}