Problem/Motivation

When trying to add a user entity type with a custom form display I get an ajax error when I hit the create button to load the user form in the modal window. I am running drupal 9.4.8

Steps to reproduce

Create a custom form mode in drupal. In my case a custom user form mode of type "participant"
Select the new mode in the entity reference modal create widget settings from whatever form is referencing the entity
Try to create the new entity in the form

Proposed resolution

I tracked the issue down to the entityreference_modal_create_entity_type_build function. The approach is correct but something may have changed in drupal core?
For some reason getFormModeOptions is not returning any of the custom form modes?
I was able to simply fix my specific issue by adding my own hook_entity_type_build
$entity_types['user']->setFormClass('participant', 'Drupal\user\ProfileForm');

CommentFileSizeAuthor
#2 3316609.patch881 bytesahmed eldesoky

Comments

mettasoul created an issue. See original summary.

ahmed eldesoky’s picture

StatusFileSize
new881 bytes

This patch fixes it

tamerzg’s picture

Status: Active » Needs review
megan_m’s picture

Status: Needs review » Needs work

I can confirm that this patch applies, gets rid of the ajax error, and makes the modal display using the correct form mode.

megan_m’s picture

Status: Needs work » Needs review

Sorry, thought I found an issue but it was a configuration problem on my part.

avpaderno’s picture

Version: 8.x-1.1 » 8.x-1.x-dev
tamerzg’s picture

Status: Needs review » Reviewed & tested by the community