Closed (fixed)
Project:
Scheduler
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2019 at 21:49 UTC
Updated:
23 Mar 2022 at 18:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jonathan1055 commentedHi xopoc,
That could be a useful enhancement. Could you point us to an example of this (maybe in another module?) or give some links to how it might actually be achieved. I do not have the spare capacity at this time to reasearch this from scratch.
Jonathan
Comment #3
bkosborneHere's a patch that removes the widget warning entirely as a stopgap for us.
Comment #4
bkosborneComment #5
tessa bakkerRe-roll of patch #4 for version 1.4
Comment #6
jonathan1055 commentedThanks Tessa Bakker.
Regarding my comment in #2 can you show me an example of where this is needed? I note that the patch in #4 is only a 'stop-gap' to remove the warning.
Also, any new changes must be done at the new 2.x dev branch first.
Comment #7
tessa bakkerWhen you create a custom widget or use a contrib widget that has some extra/custom features than the one included in the module.
Comment #8
jonathan1055 commentedThanks. Yes I understand that. What I meant was an example of an actual implementation of a different widget. Is it done via a hook function? Or is the new widget just manually set by the admin. The problem with the patch as it stands is that it just deletes the whole check for the incorrect widget, which in most sites will be a loss of functionality. This check was added in #2848213: Give warning when wrong datetime field widget is set so we need to find a way allow keep that check.
If you have a custom widget, and you re-install Scheduler, could you check to see what widget gets assigned? Does it revert to the core widget as in that issue? Is so, then the 'wrong widget check' could be altered to only report if the core widget has got set, but allow any other custom widget, or the Scheduler one.
Comment #9
bkosborneWhat we're doing is just setting it via the entity form display settings, so it's saved in config. Any field widget that is compatible with the timestamp field can be used. We created a custom one, just like you did (TimestampDatetimeNoDefaultWidget). Ours is a bit different in that it makes it easier to select a time value via a dropdown.
I can't personally test this easily, as we have a lot of modules in our install profile that declare dependency on Scheduler, so just being able to get it to be uninstalled is tricky. However, I don't think it would revert to the core widget, because the base field definitions for publish_on and unpublish_on that this module defines set the correct default to the widget that Scheduler provides. But that's contrary to experience the user had in #2848213: Give warning when wrong datetime field widget is set.
I think there's two paths forward:
Comment #10
jonathan1055 commentedHi, and sorry for the delay in replying. To answer my question about the widget getting reverted on uninstall and re-installing Scheduler, I just created another datetime widget via a testing module (i.e. not within Scheduler) to emulate your scenario, and set that to be used by Scheduler publish_on but left the original Scheduler widget for unpublish_on. Then on uninstalling and re-installing Scheduler the field setting for unpublish_on was reverted back to to plain core widget as expected (and as observed in #2848213: Give warning when wrong datetime field widget is set) however the publish_on was unaffected and remained set to the testing modules widget (I am not sure exactly how this config is retained when Scheduler is uninstalled, but I guess it is somehow not removed even though the fields are removed).
Anyway, there is a third option for a solution, and that is to only report the "wrong widget" message when it is set back to the core widget. That was the original reason for checking it. If a third-party module is providing a widget then assume they know what they are doing and leave it at that. I would rather not add a new config option to suppress the warning, and having the warning show in the status report could be just as confusing. But this third way is simple to implement with zero overhead, and achieves exactly what we want.
Comment #12
jonathan1055 commentedMR for scheduler 2.x - if you want a patch you can get it via https://git.drupalcode.org/project/scheduler/-/merge_requests/37.diff
Let me know if you are running 8.x-1.4 and I'll provide a patch, as the 2.x will not apply.
Comment #13
jonathan1055 commentedHere's a patch for the 8.x-1.x branch
Comment #14
jonathan1055 commentedReverting the Tugboat commits as I have now created a separate issue for that #3268584: Fix Tugboat config to run at core 9.3
Comment #17
jonathan1055 commentedCommitted to both branches.