Conflict with Workflow module

Created on 1 March 2021, over 4 years ago
Updated 30 May 2025, about 1 month ago

Problem/Motivation

When using the community Workflow module with transition states, autosave is triggered for workflow state form but autosave element is null

Steps to reproduce

Create a content type to be autosaved and include a Workflow field inside with multiple states/transitions

Proposed resolution

Simply add a null check before calling setSubmitHandlers so it doesn't try to set submit handlers on a null element

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇫🇷France devden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • This patch worked in our case, whereas a similar one - https://www.drupal.org/project/autosave_form/issues/3355645 🐛 TypeError: Drupal\Core\Form\FormState::setSubmitHandlers(): Argument #1 ($submit_handlers) must be of type array, null given, called in /web/modules/contrib/autosave_form/src/Form/AutosaveFormBuilder.php on line 139 i Active - did not.

    I’ll briefly describe what was happening on our end. The autosave_form module was triggering two AJAX requests handled by AutosaveFormBuilder::processForm:

    1. content_moderation_entity_moderation_form
    2. node_article_edit_form

    The first one was problematic, as it didn't include the autosave_form_save element.

    After some investigation, I found that another contributed module was altering the node_article_edit_form via hook_form_node_form_alter() and contained logic like this:

    ```
    $build = Drupal::service('entity_type.manager')
    ->getViewBuilder($node->getEntityTypeId())
    ->view($node, 'default');
    $output = Drupal::service('renderer')->render($build);
    ```

    That render call was triggering the first autosave AJAX request.

    With this patch applied, the update for content_moderation_entity_moderation_form is skipped, and only the node_article_edit_form is processed - resolving the issue.

  • The patch above causes a warning:

    ```
    Warning: Undefined array key "autosave_form_save" in Drupal\autosave_form\Form\AutosaveFormBuilder->processForm() (Zeile 129 in /data/web/modules/contrib/autosave_form/src/Form/AutosaveFormBuilder.php)
    ```

    So please find an updated patch attached

Production build 0.71.5 2024