To reproduce, say you have a form like this one:
<?php
// switching to 'bar' item should display 'dependant' text field
$form['principal'] = array(
'#type'=> 'radios',
'#title'=> 'Principal',
'#options'=> array('foo', 'bar'),
'#default_value'=> 0,
);
// should get displayed based on selection on 'principal'
$form['dependant'] = array(
'#type'=> 'textfield',
'#title'=> 'Dependant',
'#states'=> array(
'visible'=> array(
// (1) works with this, because a explicit string "1" is passed: ':input[name="principal"]' => array('value' => "1"),
':input[name="principal"]'=> array('value'=> 1), // doesn't work in IE8
),
),
);
?>
Switching 'principal' radio buttons it is expected that 'dependant' text field is displayed and hidden.
Instead, in IE8 (without uncommenting section (1)), 'dependant' visible state is never changed on 'principal' changes, the problem is because of the usage of 'reference.constructor.name' js which is not supported on IE8 and the posterior call to
function compare (a, b) {
return (a === b) ? (typeof a === 'undefined' ? a : true) : (typeof a === 'undefined' || typeof b === 'undefined');
}
Where this method compares considering types (and the actual values compared are a Number vs a String, which gets false).
I'm attaching a module to reproduce this issue easily and a patch tested on Firefox, Chome and IE8.
Notes:
Bug only found in IE8, problem could exist in newer IE versions.
Attachment | Size | Status | Test result | Operations |
---|---|---|---|---|
form_states_not_working_with_literal_integers_as_values_in_IE8.patch | 1.04 KB | Ignored: Check issue status. | None | None |
fix_problem_with_states_js.zip | 1.37 KB | Ignored: Check issue status. | None | None |