Modals with custom form display not loading

Created on 20 October 2022, about 2 years ago
Updated 2 December 2023, 12 months ago

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');

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States mettasoul

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.

  • 🇨🇦Canada megan_m

    I can confirm that this patch applies, gets rid of the ajax error, and makes the modal display. However, the correct form mode is not loading. It's using the default form mode not the one I have configured the modal to use. I'm not sure if that's a separate issue or not.

  • Status changed to Needs review over 1 year ago
  • 🇨🇦Canada megan_m

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

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024