Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#16512 closed defect (fixed)

dijit.form.CheckBox HTTP POST broken in IE 7, 8

Reported by: getittogether Owned by: Douglas Hays
Priority: undecided Milestone: 1.8.4
Component: Dijit - Form Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

The dijit CheckBox? widget does not pass POST data in IE 7-9

The following snippet works as expected in:

  • Dojo 1.8.1
  • Dojo 1.8.3 + Firefox

It does not work in:

  • Dojo 1.8.3 + IE 7-9

Send a HTTP POST request with a dijit checkbox. This problem can also be reproduced when using dojo.xhrPost with the 'form' attribute filled.

File: index_dijit.php

<form id="myForm" dojoType="dijit.form.Form" method="post" action="index_dijit.php">
    <input name="test" id="test" dojoType="dijit.form.CheckBox" /> Test
    <input type="submit" value="Submit" />
</form>

<?php
    print_r($_POST);
?>

Attachments (1)

16512.patch (475 bytes) - added by Douglas Hays 7 years ago.
fix for IE < 9

Download all attachments as: .zip

Change History (18)

comment:1 Changed 7 years ago by Douglas Hays

I'm not sure I understand the problem. In the provided example, the CheckBox is not checked and so it should not submit test=on with the POST data. What are you expecting to be submitted?

comment:2 Changed 7 years ago by bill

Owner: changed from Douglas Hays to getittogether
Status: newpending

Sounds like a difference in behavior of how IE and other browsers handle native unchecked checkboxes when submitting forms, rather than an issue with dijit?

comment:3 in reply to:  2 Changed 7 years ago by getittogether

Status: pendingnew

Replying to bill:

Sounds like a difference in behavior of how IE and other browsers handle native unchecked checkboxes when submitting forms, rather than an issue with dijit?

I'm sorry, I meant to add that it does not submit the "on" data even when the dijit checkbox is checked.

comment:4 Changed 7 years ago by bill

Owner: changed from getittogether to Douglas Hays
Status: newassigned

That's very strange, because it's using a native checkbox underneath the pretty one.

comment:5 Changed 7 years ago by Douglas Hays

Resolution: worksforme
Status: assignedclosed

This is working for me. Of course your snip-it doesn't load Dojo so it can't work standalone nor does it set type=checkbox. Here's my working standalone example:
http://doughays.dojotoolkit.org/work/index_dijit.php

comment:6 in reply to:  5 Changed 7 years ago by getittogether

Replying to doughays:

This is working for me. Of course your snip-it doesn't load Dojo so it can't work standalone nor does it set type=checkbox. Here's my working standalone example:
http://doughays.dojotoolkit.org/work/index_dijit.php

Thanks for setting up the example, but I'm seeing the same erroneous behavior when visiting your test site: The array is empty after ticking the checkbox and clicking Submit (IE7, which is unfortunately what most of our users have installed).

There may be something in my company's environment that causes IE7 + Dojo 1.8.3 to handle checkboxes differently, however the problem isn't present in Dojo 1.8.1, which leads me to believe something changed between Dojo 1.8.1 and 1.8.3.

comment:7 in reply to:  5 Changed 7 years ago by getittogether

Replying to doughays:

This is working for me. Of course your snip-it doesn't load Dojo so it can't work standalone nor does it set type=checkbox. Here's my working standalone example:
http://doughays.dojotoolkit.org/work/index_dijit.php

I think I've found a potential fix for the issue I'm seeing. I've narrowed the problem down to a commit to Dojo 1.8.2: r29816.

Specifically, in: http://bugs.dojotoolkit.org/changeset/29816/dojo/dijit/trunk/form/_ToggleButtonMixin.js

On line 36,

node.setAttribute("checked", "");

might need to be:

node.setAttribute("checked", !!value);

When this change is made, IE7 passes the checked state correctly.

comment:8 Changed 7 years ago by bill

Did you mistype your suggestion? Looks like [29816] changed it from node.setAttribute("checked", "") to node.setAttribute("checked", !!value), and that's when the problem on IE7 started for you. The latter looks suspicious to me since it's setting an attribute to a non-string value.

comment:9 in reply to:  8 Changed 7 years ago by getittogether

Replying to bill:

Did you mistype your suggestion? Looks like [29816] changed it from node.setAttribute("checked", "") to node.setAttribute("checked", !!value), and that's when the problem on IE7 started for you. The latter looks suspicious to me since it's setting an attribute to a non-string value.

No, my suggestion is to replace the blank string with !!value. r29816 seemed to delete the attribute on the node, which possibly caused the IE7 problem.

Instead of setting the attribute to "!!value", I think a non-empty string might work too; I was just following the pattern on line 34.

comment:10 Changed 7 years ago by bill

Resolution: worksforme
Status: closedreopened

I see.

Doug, in any case, this reproduces for me, when loading http://doughays.dojotoolkit.org/work/index_dijit.php on IE7 and then clicking the checkbox and pressing submit, it displays an empty result rather than listing the checkbox as checked.

Changed 7 years ago by Douglas Hays

Attachment: 16512.patch added

fix for IE < 9

comment:11 Changed 7 years ago by Douglas Hays

Milestone: tbd1.8.4

comment:12 Changed 7 years ago by Douglas Hays

Summary: dijit.form.CheckBox HTTP POST broken in IE 7, 8, 9dijit.form.CheckBox HTTP POST broken in IE 7, 8

comment:13 Changed 7 years ago by Douglas Hays

Resolution: fixed
Status: reopenedclosed

In [30286]:

Fixes #16512. Set checked attribute to "checked" instead of an empty string so that older IE sees it.

comment:14 Changed 7 years ago by Douglas Hays

In [30462]:

Refs #16621, #16512. Blank RadioButton? value was being set to "on" after reset which is incorrect (but correct for CheckBox? widgets). Removed unnecessary set/removeAttribute(checked) calls since only domAttr.set is needed for the checked attribute. Don't call domAttr.set if already set correctly to keep IE from losing tab order. Added automated tests.

comment:15 Changed 7 years ago by Douglas Hays

In [30469]:

Refs #16621, #16512. Cannot specify CHECKED in the CheckBox? template since this messes up IE6-8 radio button tab order. Instead run setAttribute('checked','checked') in postCreate. Added additional automated test.

comment:16 in reply to:  15 Changed 7 years ago by mraulers

Replying to doughays:

In [30469]:

Refs #16621, #16512. Cannot specify CHECKED in the CheckBox? template since this messes up IE6-8 radio button tab order. Instead run setAttribute('checked','checked') in postCreate. Added additional automated test.

Will this fix the same behavior found within radio buttons? I recently rolled back an upgrade to 1.8.3 due to issues with radio button checked behavior and IE 7 not realizing that the buttons had been selected and always returning false even if the attribute was set with checked="". The fix suggested above seems to have fixed this issue for me, but you seemed to conclude that this fix could not be made to the location specified without breaking the tab behavior.

Last edited 7 years ago by mraulers (previous) (diff)

comment:17 Changed 7 years ago by Douglas Hays

Radiobutton inherits from CheckBox? so these issues should be fixed there as well.

Note: See TracTickets for help on using tickets.