This is somewhat related to: https://www.drupal.org/node/2498699

I was wondering if it was possible to use Webform Conditionals to set a date using the "set to" function in Conditionals.

I saw the reasoning in the issue above for the 'set to Number' and how it was resolved, so I'm wondering if the same sort of resolution could be found for Date fields.

I'm using Webform for employees to submit timesheets. They select a pay period (select list of date ranges), so it would be great if the date fields could be auto-populated based on their selection of Pay Period. It seems like the "set to" Condition could do this, but not in its current state (error message when trying to set date fields).

Thanks for any help!

Comments

kyleheney’s picture

Issue summary: View changes
DanChadwick’s picture

Status: Active » Closed (won't fix)

Two part answer.

First, the SET TO action can only set fixed data that is specified in the conditional. It can't copy or extract information from another component. Therefore I don't see how it would help you, even if data components were supported.

Second, Date components are much more complicated because there isn't a single interface element, but up to 4 (month, day, year, date picker). If someone wants to tackle this support, I would support a patch. I however don't plan to do so, absent sponsorship.

kyleheney’s picture

Thanks for the reply.

RE: First ---> I wasn't really hoping for it to extract data from another component, rather use that static selection (say "Pay Period 2") in the conditional statement, then say "IF (select list) = "Pay Period 2", then (date 1) set to "July 20 2015"... this would need to be done for each date in the pay period. i.e. I wasn't expecting the one selection to be able to populate the fields through one conditional statement, I know several statements would be required.

RE: Second ---> I definitely recognize that dates would be trickier due to all the elements. I wonder if I could accomplish what I'm after by just using textfields for the dates and marking them as uneditable... it may take away some functionality in terms of analysis, but may give me the "set to" requirements I'm looking for.

Can I ask, is there a recommended limit for Conditionals per Webform? This sort of idea would basically involve a Conditional for every day of the year...

DanChadwick’s picture

Re 1) At present, you can have only one conditional set any one particular component. This is to avoid the situation where more than one is active at a time.

2) You can use text fields and set them, but you are still subject to the limit above.

I would not attempt to have 365 conditionals. You just need to write yourself some custom jQuery and PHP to do this.