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

samuel.mortenson created an issue. See original summary.

phenaproxima’s picture

Issue tags: +Media Initiative
phenaproxima’s picture

Title: [PP-1] Use #element_validate for the upload element in the MediaLibraryUploadForm » Use #element_validate for the upload element in the MediaLibraryUploadForm
Status: Postponed » Active

Blocker is in!

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

phenaproxima’s picture

phenaproxima’s picture

Status: Active » Closed (outdated)

This 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.

darvanen’s picture

This 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?:

  1. Remove the @todo, or
  2. Reopen ticket to factor out all validation into a separate code block

I'm about to suggest on the related ticket that the new validations be placed in FileItem instead of FileUploadForm.

matthiasm11’s picture

Status: Closed (outdated) » Needs work

As mentioned in the previous comment, there still is a todo in FileUploadForm.php.

quietone’s picture

Status: Needs work » Closed (outdated)

Yes, 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