Problem/Motivation
Client side validation doesn't work on file input (https://www.drupal.org/project/clientside_validation/issues/2905554).
Proposed resolution
Forward the #required attribute of form field to upload element (see patch).
Since validation for multiple value file fields will be complex, proposed solution is to make it work at-least for single value field.
Remaining tasks
- update tests / code
- reviews needed
- tests required?
User interface changes
HTML5 validations will start working for file input fields.
API changes
N/A
Data model changes
N/A
Created separately instead of commenting in https://www.drupal.org/project/drupal/issues/1174938 as this one is specific for managed_file input and forwarding attributes from field to child element and not actually set the aria attribute.
| Comment | File | Size | Author |
|---|
Issue fork drupal-2938441
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nikunjkotechaComment #4
nikunjkotechaComment #5
nikunjkotechaUnderstood how FunctionalJavascript/JavascriptTestBase works and after checking the failure scenarios, it seems it is far more complex to achieve this.
Keeping this ticket open for now as it is still not working as expected even for normal HTML5 standards.
Comment #6
nikunjkotechaTrying to fix in a hacky way just to check if it can work.
Comment #7
nikunjkotechaIMO, this is open for review and most importantly - validate the solution / provide better approach for doing this.
Comment #11
arun ak commentedThis patch is not working with 8.x-5.2.
Comment #13
anruetherThe patch from #6 applies to drupal 8.9.1 but clientside_validation doesn't work for me on a media reference field with media library widget and image/document enabled. (Also drupal validation usually outputs the field name, but for media fields only see
This value should not be null.edit: this also happens without the patch applied)Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #22
volegerRerolled #6
Comment #23
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
As a bug this will need a test case.