Problem/Motivation

This error can occur if autosave processes a non-entity form:

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

Steps to reproduce

Use another module that also adds an additional separate form builder form to the page.

Proposed resolution

Check that the form being process

Remaining tasks

Review merge request

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 3355645-1.patch764 bytesabhinand gokhala k
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

Abhinand Gokhala K created an issue. See original summary.

abhinand gokhala k’s picture

StatusFileSize
new764 bytes

Solved the issue.

abhinand gokhala k’s picture

Assigned: abhinand gokhala k » Unassigned
Status: Active » Needs review
gaurav_manerkar’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks.

tomefa’s picture

Thanks, the patch also work for me and solve this issue !

hchonov’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Could you please elaborate on how this can be reproduced? In this function apparently we are running into an autosave submission, but the autosave submit element is not there, which does not seem right.

scott_euser made their first commit to this issue’s fork.

scott_euser’s picture

Title: 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 » Autosave Form Builder processes forms that are not the entity form if there are multiple forms on the add or edit entity page
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
Related issues: +#3505659: Error when using autosave_form module

Okay this was reproduced here #3505659: Error when using autosave_form module

The issue occurs if any other form is built on the same page as a form where an autocomplete is build. This is because AutosaveFormBuilder takes over from FormBuilder and assumes the form being acted on is the entity form, yet it is possible to have multiple forms on the page. AutosaveFormBuilder should check if the form being acted on is one it has altered first.

The patch is okay, but actually would be better to just bail earlier and delegate back to FormBuilder from core if its a form that we don't care about here. Merge request with that earlier bailing out created + comment added with explanation for future us.

milosr’s picture

Status: Needs review » Reviewed & tested by the community

Tested and works.