So far the form widget for the schedulers fields hardcoded to 'datetime_timestamp_no_default'.
It does not allow to extend the schedulers fields with custom form widgets with better usability.
Proposed resolution: remove strict hardcoded check of the form widget with something more flexible, like implementation of interface or extending of abstract class, etc.

Issue fork scheduler-3037483

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

xopoc created an issue. See original summary.

jonathan1055’s picture

Title: Remove hardcoding of the form widget » Remove hardcoding of the form widget name
Status: Active » Postponed (maintainer needs more info)

Hi 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

bkosborne’s picture

Here's a patch that removes the widget warning entirely as a stopgap for us.

bkosborne’s picture

tessa bakker’s picture

Re-roll of patch #4 for version 1.4

jonathan1055’s picture

Version: 8.x-1.x-dev » 2.x-dev

Thanks 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.

tessa bakker’s picture

When you create a custom widget or use a contrib widget that has some extra/custom features than the one included in the module.

jonathan1055’s picture

Thanks. 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.

bkosborne’s picture

Status: Postponed (maintainer needs more info) » Active

Thanks. 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.

What 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.

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?

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:

  1. - Move the message to hook_requirements so it shows up on status page instead of node form. Or maybe move it to the entity form display for the entity type instead.
  2. - Add a config settings - which defaults to TRUE on new and existing sites, to toggle the display of this message. That way anyone that is using their own custom widget can disable the message easily.
jonathan1055’s picture

Hi, 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.

jonathan1055’s picture

Title: Remove hardcoding of the form widget name » Do not give warning for wrong widget if it is provided by a third-party module
Status: Active » Needs review

MR 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.

jonathan1055’s picture

StatusFileSize
new1.63 KB

Here's a patch for the 8.x-1.x branch

jonathan1055’s picture

Reverting the Tugboat commits as I have now created a separate issue for that #3268584: Fix Tugboat config to run at core 9.3

  • jonathan1055 committed 1005792 on 2.x
    Issue #3037483 by jonathan1055, bkosborne, Tess Bakker: Do not give...

  • jonathan1055 committed 8578023 on 8.x-1.x
    Issue #3037483 by jonathan1055, bkosborne, Tess Bakker: Do not give...
jonathan1055’s picture

Status: Needs review » Fixed

Committed to both branches.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.