Problem/Motivation
In \Drupal\media_library\Form\MediaLibraryUploadForm::buildForm, a #process callback is used to validate the cardinality of an upload. This was done as, in the developer's testing, #element_validate does not function properly when the element is submitted using AJAX.
This is functional for this use case, but we should figure out why #element_validate didn't work and fix the problem in core or the media_library module.
Proposed resolution
Move the ::validateUploadElement process callback into #element_validate .
Remaining tasks
Figure out the work required to do this, open more issues or change this issue's component if necessary.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
phenaproximaComment #3
phenaproximaBlocker is in!
Comment #5
phenaproximaComment #6
phenaproximaThis is an old issue that was opened for the Media Library prototype that landed in Drupal 8.6. In 8.7, the UI and related paradigms were largely redone and refactored, and some foundational APIs were put in place, so this issue no longer applies. Closing.
Comment #7
darvanenThis issue still has a @todo on line 153 of \Drupal\media_library\Form\FileUploadForm as of 9.1.6
#3008292: ImageItem::getUploadValidators() should be the source of truth for validating uploaded images is attempting to add some much-needed conditional validation for images.
Request direction regarding way forward?:
I'm about to suggest on the related ticket that the new validations be placed in FileItem instead of FileUploadForm.
Comment #8
matthiasm11 commentedAs mentioned in the previous comment, there still is a todo in
FileUploadForm.php.Comment #9
quietone commentedYes, there is still work to do but this issue is listed on the issue tracking @todos for closed issues, #3123832: [META] Fix @todo items referencing closed issues. Therefor, this can remain closed. The work will happen when someone decides to work on fixing it.
I am restoring the status set in #6