I am using the fullcalendar_view module. With that, it provides a field for having events repeat each week. And that is a dropdown list of values 0-6 to represent Sun-Sat.
I was able to get prepopulate working with this field.
?edit[field_weekly_event][widget]=4
would set the field to Thursday as expected. In fact, it worked for all days except Sunday which has a value of 0.
So this
?edit[field_weekly_event][widget]=0
would not work. It would cause the passed in variable of $form and $request_slice not to work with each other and thus not set anything.
After some digging, I tracked this down to a logic issue in src/Populate.php in a recursive function named populateForm. There was an if statement that read the 0 value causing it to return false when that wasn't the intent of the if. I rewrote that if statement to better handle the NULL check and in a way that I felt was more readable. It now works for me on Sunday and the other days. Hoping folks can confirm this is a good fix. I'll post my patch file shortly.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3060341-16.patch | 5.36 KB | heddn |
| #16 | 3060341-16_test_only.patch | 4.72 KB | heddn |
Comments
Comment #2
eahonet commentedHere's the patch I made. I hope I made it correctly.
Comment #3
eahonet commentedComment #4
heddnCould we add some test coverage of this?
Comment #5
eahonet commentedI can try creating a test. This is my first attempt at modifying the tests and I wasn't able to determine a way to test it on my environment.
Comment #6
eahonet commentedI welcome guidance on how to properly setup the tests for this. The code change is sound, but I obviously am missing something on the testing code. I'm not sure how to test locally, and don't want to spam d.o with tests.
If someone is running into this issue right now, #2 has a solution.
Comment #7
heddnTry with single quotes around these values i.e. '0', etc.
Comment #8
eahonet commentedTrying an updated patch with single quotes around the numbers. Thank you @heddn
Comment #9
eahonet commentedRealized I was missing a file. Going to try without single quotes around value too.
Comment #10
heddnThe label should be what you have in the expectations, "Select List Numeric 0", etc.
Comment #11
eahonet commentedAh. So perhaps having the ' around the label caused the output to be different. Modeling this off of the field_select_list and originally I had missed the field definition file. So going back to no single quotes and with the correct definition file (all modeled off of field_select_list test). Trying again. Thank you for patience @heddn.
Comment #12
eahonet commentedFound two other files that had field_select_list but not my field_select_list_numeric. Trying new test included patch.
Comment #13
eahonet commentedChanging type from list_string to list_integer
Comment #14
eahonet commentedChanging 0 to Zero and adjusting the test php file.
Comment #15
eahonet commentedWell, that was an embarrassing level of patch submits to get the test working. But changing to "Needs review" now that my test works.
Comment #16
heddnAdding a test only patch to see the failures. This is coming together quite nicely. Thanks for your efforts.
Comment #19
heddn