Closed (fixed)
Project:
Scheduler
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Jan 2016 at 17:48 UTC
Updated:
24 Mar 2016 at 20:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jonathan1055 commentedIt has taken a while to investigate but I have a working version of the default-time processing. The change is small, it required a #value_callback function on our customised datetime widget. I tried to do the manipulation in the existing massageFormValues function, but that is too late - the validation has already been done and if a time is omitted the error message is already created. The valueCallback method works on user input before validation, which is what we need.
In this patch I've placed the callback function as a normal helper function in .module but it would be nicer if it was contained within the
TimestampDatetimeNoDefaultWidgetclass. However, when I tried this, I got errors about uninitialised 'date' offset in datetime.php, and the new callback did not seem to be executed. I also tried creating a function named valueCallback in the TimestampDatetimeNoDefaultWidget class, hoping that this would be called instead of the standard Datetime::valueCallback, but it was not being executed. Maybe someone with more OO experience will be able to help on this. I've left comments about this in the code.Comment #4
jonathan1055 commentedGood. As I hoped, this now fixes the date tests entirely.
My manual testing was working correctly too, so functionally this is now operating as required. But it would be better to have the callback included in the widget class, so any help on how to get that working would be appreciated.
Comment #5
jonathan1055 commentedI've now got the correct syntax for #value_callback to be a function within the same class:
Code is much neater, now all contained within
TimestampDatetimeNoDefaultWidgetComment #7
jonathan1055 commentedSame as before, this fixes SchedulerDateCombinedFunctionalTest.
Setting back to 'needs review' as it would be good to have someone else cast an eye over the code before I commit.
Comment #8
pfrenssenAssigning for review as part of the global sprint in Sofia.
Comment #9
pfrenssenLet's keep these, this is a generic reusable field widget after all, we might use it outside the node edit form in the future.
Using the valueCallback() is a really elegant solution for this problem. Great work!
This has to be a public static function.
Duplicate space before the '='.
Comment #10
jonathan1055 commentedThanks for the review, really helpful.
The only use for $date_format and $time_format is in creating $element['value']['#description'] which we completely overwrite in scheduler_form_node_form_alter(). Maybe there should be a comment saying where this function was copied from? I don't quite see the point in leaving in unused variables and creating a #description which gets overwritten, as it gives the misleading impression that these lines are doing something. But happy to leave them in, provided a comment says that they are currently redundant.
I will re-roll the patch when I understand what you want in (1). Will be good to get this committed as it fixes a whole test class.
Thanks again for the review. Hope your global sprint in Sofia went well.
Comment #11
jonathan1055 commentedThinking about it more, I get your point about not leaving an incorrect #description in the widget, even if that description is not currently being used. I have added a comment to explain this, and addressed the other issues. Also slightly altered the description to say 'for no date' instead of 'to disable'.
Here's the patch and interdiff.
Comment #13
jonathan1055 commentedSwitching back to 'needs review' as I have finished the changes. Unless anyone has further questions/suggestions/review observations I think this is ready to commit.
Comment #15
jonathan1055 commentedIt's been a month with no objections, so decided to commit the patch from #11. I will make adjustments if required, but everything in the review in #9 was addressed.
Nice to get another test class fully passing.
Comment #16
pfrenssenJust did a quick review. Looking good!