A few weeks ago, I was working on one of our client’s sites, built on the Symfony 1.4 framework. We were having trouble with a page littered with asynchronous Javascript code, and seeing timing and data issues. After an hour of debugging, I tracked down the issue to a crucial behavioural tick that was fixed in a later release of JQuery. Updating was pretty painless, and testing on that page and the rest of the site seemed to have given us a touch of a speed up as well. Going from 1.4.2 to the latest patched 1.6 had been a smooth ride.
Quickly though, our integration testing raised a problem. The date
selectors littered throughout the system were now acting screwy. We’re
using thesfFormWidgetExtra
plugin to get date pickers for the date
fields on forms. This gives two things:
- A three combo box selector for the day, month and year, which can be adjusted to add a time as well, handy for precise selection
- A datepicker button to give you a formatted, JQuery UI date picker.
Although the date picker was working normally, the day selector in the
drop down had all
the <options>
set to disabled. The options loaded correctly, such that
the currently selected option was selected, but now
as a user you had to use the date picker to select the day.
Weird right? I dug around the widget display code for a bit and couldn’t find much. But then I found this old ticket in the Symfony bug tracker, and all was made clear.
The detail is in the bug but in summary, JQuery changed the way it
accesses DOM properties versus attributes, but sfFormExtra hasn’t been
updated to change this. There are two solutions: one is that you write
your own widgets that inherit from the provided widgets, and then update
the template code there. The second is lazier, but on a given project
you can just update the code yourself in the sfWidgetFormJqueryDate
and sfWidgetFormJqueryDateTime
classes. Since we were short of time, I
did the latter, which resolved the issue.
However, I’m intending on going back and writing a widget for it. This will let us better track the differences as JQuery gets updated on these old projects, and will also let us keep any other changes in line.