Problem/Motivation
The hook_form_workflow_transition_form_alter documented in workflow.api.php is no longer available.
It seems like this is a regression caused by this commit:
https://git.drupalcode.org/project/workflow/-/commit/69e651a039b9cb406e8...
The WorkflowTransitionForm::createInstance method usage was replaced by WorkflowTransitionForm::retrieveFormElement, which does not call the form builder anymore (which was responsible for calling alter hooks).
Steps to reproduce
Implement a hook_form_workflow_transition_form_alter, observe it's not being called.
Proposed resolution
Mimic the \Drupal\Core\Form\FormBuilder::prepareForm(), call the alter hooks the same way it does.
Remaining tasks
Review & testing.
User interface changes
None.
API changes
Fix of the API regression.
Data model changes
None.
Issue fork workflow-3545610
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
Comment #3
abrammReady for review.
Comment #4
abrammNote: after a deeper look, it seems like the regression only applies to the field widget. The standalone transition form shouldn't be affected.
Comment #5
johnvIndeed, i have a long term problem that the history view, the node view with worklowform and Block use 1 code flow, and the Node edit Form use a (proper) widget.
In v1. 8 and v2.x, at least i manager to avoid code duplication (saving a transition twice).
BTW, v1. 8 is regarded harmful, since it break too many custom code.
Comment #7
johnvThanks. committed.
Comment #10
johnvPff, now the workflowtransitionform is not displayed at all on the Node View page, when you have it configured as Formatter....
I think it has nothing to do with your change, but with #3545042: Introduce WorkflowItem::$list_class = "WorkflowItemList" and deprecate WorkflowTargetEntity
Comment #11
johnvThe problem above is luckily solved with #3545042-26: Introduce WorkflowItem::$list_class = "WorkflowItemList" and deprecate WorkflowTargetEntity
Comment #12
johnvRegarding the OP.
I peeled off
// $element = $form_builder->retrieveForm($form_id, $form_state);in order to get a nicer, small, cleaner $element, resulting in
$element = $form_object->buildForm($form, $form_state);.Ofcourse, the goal is missed if additional code needs te be inserted, was we did just now.
Let me sest this to active again, and sleep some nights about it.
Comment #13
johnvPlease check latest version.
The hooks are now applied to the form (as core design and expected)
The hooks are now NOT applied to the widget (as core design and expected).
Do you expect the hooks to be applied on the widget?
For that you can use field.api.php function hook_field_widget_single_element_form_alter
Comment #14
johnv