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.
This data is invariant for a widget, there's no need to calculate it a ton of times.
Comment | File | Size | Author |
---|---|---|---|
#5 | office_hours_1913034.patch | 0 bytes | johnv |
#3 | office_hours-1913034.patch | 4.8 KB | jonhattan |
#1 | office_hours-1913034.patch | 5.06 KB | jonhattan |
Comments
Comment #1
jonhattanAnother benefit of this change is that form elements are simpler since we send less parameters through.
Comment #2
jonhattanAbove patch includes an unrelated change in _office_hours_slot_validate():
This is only met if the user hijacks a select element with firebug or similar. Drupal does its own validation for this case.
OTOH:
This is easier than calling date_hours() and filtering results afterwards.
Comment #3
jonhattanCoding standards.
Comment #4
johnvThis is not working for two reasons:
You are moving calculations from _process() to _widget_form(), which (minimally) slows down the rendering of the page. In the current situation, the calculation is upon submitting the page, when already all heavy lifting is being executed.
Also _widget_form is executed 28 times. (This might be fixed with your last and final patch for the week-widget)
But above all: it is not working with a 12-hour clock and hours after 12:00, and is breaking existing data when changing from 24-hour clock to 12-hour clock.
Comment #5
johnvForget my previous post. I was confused.
Attached patch is committed here.
I also contains the following:
- changes in css to be able the block element in nomal forms.
- corrected the non-working hours limits when working in 12hr mode.
Comment #6
johnvAdded another fix.
I removed the hook_field_presave(), and moved the functionality to the widget_form, since the hook_field_presave() and hook_field_load() are not loaded on the widget settings page, where we now have a multivalue default value.
See #1944678: On field settings form, hook_field_load() and hook_field_presave() are not called. .