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

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

abramm created an issue. See original summary.

abramm’s picture

Status: Active » Needs review

Ready for review.

abramm’s picture

Note: after a deeper look, it seems like the regression only applies to the field widget. The standalone transition form shouldn't be affected.

johnv’s picture

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

  • johnv committed 826e42bb on 2.1.x
    Issue #3545610 by abramm: hook_form_workflow_transition_form_alter is no...
johnv’s picture

Title: The hook_form_workflow_transition_form_alter is no longer available » hook_form_workflow_transition_form_alter is no longer available
Version: 2.1.x-dev » 2.1.7
Status: Needs review » Fixed

Thanks. committed.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • johnv committed 20d1fe5f on 2.1.x
    Issue #3545610 by abramm: WorkflowTransitionForm - normalize  parameter
    
johnv’s picture

Pff, 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

johnv’s picture

johnv’s picture

Status: Fixed » Postponed (maintainer needs more info)

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

johnv’s picture

Please 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

johnv’s picture

Status: Postponed (maintainer needs more info) » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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