Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | webform-intrapage_date_time_conditionals-2220665-3.patch | 3.17 KB | DanChadwick |
Comments
Comment #1
quicksketchI 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.
Comment #2
epersonae2 CreditAttribution: epersonae2 commentedI 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.
Comment #4
DanChadwick CreditAttribution: DanChadwick commentedTwo 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.
Comment #5
epersonae2 CreditAttribution: epersonae2 commentedThank you! It works great now. :)