protected function buildInputElement(array
$form, FormStateInterface
$form_state) { // Create a file item to get the upload validators.
$media_type =
$this->
getMediaType($form_state);
$item =
$this->
createFileItem($media_type);
/** @var \Drupal\media_library\MediaLibraryState $state */
$state =
$this->
getMediaLibraryState($form_state);
if (!
$state->
hasSlotsAvailable()) { return $form;
} $slots =
$state->
getAvailableSlots();
// Add a container to group the input elements for styling purposes.
$form['container'
] =
[ '#type' => 'container',
];
$process =
(array) $this->elementInfo->
getInfoProperty('managed_file', '#process',
[]);
$form['container'
]['upload'
] =
[ '#type' => 'managed_file',
'#title' =>
$this->
formatPlural($slots, 'Add file', 'Add files'
),
// @todo Move validation in https://www.drupal.org/node/2988215