Closed (duplicate)
Project:
Drupal core
Version:
8.3.x-dev
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Apr 2016 at 12:45 UTC
Updated:
8 Jun 2017 at 14:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jrockowitz commentedI can confirm that this is an issue.
It is due to the #attributes being reset via template_preprocess_file_managed_file().
As soon as
$variables['attributes'] = array();is removedtemplate_preprocess_file_managed_file()the #states API starts working as expected.Comment #4
deltahex commentedThe same problem exists for the "datetime" form field as well. The template_preprocess function is identical but the above solution is not applicable in this case. I will spend some time on it and will provide an update here.
Also there is a duplicated "id" attribute for the element wrapper div and the file input element itself.
Comment #5
wheelercreek commentedI don't know if this is related, but when using filefields on a wizard page (multi-page) YAML form, I'm suddenly getting these warnings about array expected..
Comment #6
Anonymous (not verified) commentedIndeed, the
drupal_process_states()uses thedata-drupal-statesattribute to pass JSON encoded data to theDrupal.behaviors.states.Comment #7
Anonymous (not verified) commentedComment #10
idebr commentedHello everyone,
This issue was also reported at #2847425: #states not affecting visibility/requirement of managed_file. The related issue has a patch and contains an automated test to prevent this bug from occurring in the future.
I'll close this issue as a duplicate, so we can focus our efforts in the related issue.