Dynamically populated (via JS) checkboxes won't validate

I have a Gravity Form where the user selects a Job from a dropdown field and then one or more Shifts from a checkbox field.

The Job dropdown is populated dynamically based on what Jobs are available at that time (this is done using the gform_field_content hook - Jobs are custom posts).

The Shifts checkbox field is empty until the user selects a Job from the dropdown. At that time, I update the checkbox field’s checkboxes via jQuery. I do it this way because, obviously, I don’t know what Job the user will choose when I’m rendering the form. So during the gform_field_content hook, I store available Shift IDs (and dates/times) on the Jobs’ option elements. Then it is fairly easy to use those to update the checkbox field to show the Shifts via jQuery.

The problem is that the form fails validation (both the Job and Shifts fields are required). I believe this is happening because Gravity Form’s internal record of what is in that Shift checkbox field does not get updated when I updated it via jQuery. I can see this when stepping through the code on form submit - the checkbox’s $field object still shows the default ‘First Choice’, ‘Second Choice’, etc options and not the ‘Saturday 9:00am-11:00am’, etc. options it was set to on the frontend.

I have tried calling .change() on the checkboxes and the field itself when the user clicks a checkbox with no luck (I’d read you could do this elsewhere).

Is there some other way to achieve this? I’m not sure what to try next. This seems like it should be fairly straight-forward. Any ideas?

FWIW 1: There are ~30 Jobs at any given time and each can have 1 to 12 or so Shifts. So I was trying to avoid making a bunch of Shifts checkbox fields and then just hiding or showing them based on what Job is picked. (It is actually more complicated than this - the user can select up to 3 different Jobs so ~540 Shifts in total… figure that’ll run slow and be loads of fun to maintain)

FWIW 2: I am running Wordpress 5.1.1 and Gravity Forms 2.3.1.1.

Thanks!

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.