// 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
'#process' =>
array_merge(['::validateUploadElement'
],
$process,
['::processUploadElement'
]),
'#upload_validators' =>
$item->
getUploadValidators(),
'#multiple' => TRUE,
// Do not limit the number uploaded. There is validation based on the
// number selected in the media library that prevents overages.
// @see Drupal\media_library\Form\AddFormBase::updateLibrary()
'#cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
'#remaining_slots' =>
$slots,
];
$file_upload_help =
[ '#theme' => 'file_upload_help',
'#upload_validators' =>
$form['container'
]['upload'
]['#upload_validators'
],