In testing another issue, I noticed that I could not make date conditionals work at all the same-page. I tried both 'is at' and 'is before'. They seem to work fine as multi-page. I also tested select 'is' on the same page and that worked fine.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

I can't reproduce this problem. I set up a form with a date field and a text field. I made the default value of the field "today". Then I set up a conditional that said "If date field is before today hide text field". On page load, the field is shown. If I change the date to one day before, the field is hidden, as it should be.

epersonae2’s picture

I had the same issue.

Very simple form, two fields: a date field and a select options field. (The same issue occurred with a date field and a text field.)

The condition: "If the date is after today, show the field."

When they were on the same page, selecting *any* date showed the field.

The same thing happened if the rule was "If the date is after today, hide the field." -- Selecting any date hid the field.

If I put the select options field on the next page, then it worked correctly.

  • DanChadwick committed 82e1fcb on 7.x-4.x
    Issue #2220665 by DanChadwick: Fix intra-page date and time conditionals...
  • DanChadwick committed e6fd815 on 8.x-4.x
    Issue #2220665 by DanChadwick: Fix intra-page date and time conditionals...
DanChadwick’s picture

Status: Active » Fixed
FileSize
3.17 KB

Two problems. One easy, one harder.

The easy is that the jQuery Drupal.webform.conditionalOperatorDateEqual calls Drupal.webform.timeValue rather than dateValue.

The harder is that 32-bit hardware doesn't support UNIX Epoch time format converted to milliseconds (the format used by javascript Date.UTC()). Dates around the current date just barely fit in 32 bits. Javascript uses 64 bit floating point numbers, which have a 53 bit mantissa. This is sufficient for milliseconds.

Rather than sending milliseconds to the browser, the solution is to send seconds and do the conversion in javascript.

epersonae2’s picture

Thank you! It works great now. :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.