Commit 29b0e1b7 authored by webchick's avatar webchick

Issue #1589176 by nod_, Wim Leers: Follow-up: Use data-* to store #states api informations.

parent b6ec2ac4
......@@ -2715,7 +2715,12 @@ function drupal_process_attached($elements, $dependency_check = FALSE) {
*/
function drupal_process_states(&$elements) {
$elements['#attached']['library'][] = array('system', 'drupal.states');
$elements['#attributes']['data-drupal-states'] = JSON::encode($elements['#states']);
// Elements of '#type' => 'item' are not actual form input elements, but we
// still want to be able to show/hide them. Since there's no actual HTML input
// element available, setting #attributes does not make sense, but a wrapper
// is available, so setting #wrapper_attributes makes it work.
$key = ($elements['#type'] == 'item') ? '#wrapper_attributes' : '#attributes';
$elements[$key]['data-drupal-states'] = JSON::encode($elements['#states']);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment