From the issue for the Webform module:

When making a file upload element conditionally required when another field is filled or another option is chosen, the field doesn't become required.

Steps to reproduce:

1. Create a form
2. Create a radiobutton element
3. Option A and option B
4. Create a file upload element and a textfield, set them to not required
5. Through #state API, make them required when radiobutton element has Option A selected
6. Select option A and submit the form
7. The form is submitted

The states api does not update the file field required attribute.
Some example forms yml files were attached to the Webform issue.


artureiji created an issue. See original summary.

artureiji’s picture

Maxfire’s picture

Assigned: Unassigned » Maxfire

I'm going to work in this issue.

Maxfire’s picture

Assigned: Maxfire » Unassigned
amateescu’s picture

Component: field system » forms system
idebr’s picture

Status: Active » Closed (duplicate)
Related issues: +#2847425: #states not affecting visibility/requirement of managed_file


This was reported earlier at #2847425: #states not affecting visibility/requirement of managed_file. Can you have a look at the related issue and see if the patch fixes your problem as well?

I'll close this issue as a duplicate, so we can focus our efforts in the related issue.