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');
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3316609.patch | 881 bytes | ahmed eldesoky |
Comments
Comment #2
ahmed eldesoky commentedThis patch fixes it
Comment #3
tamerzg commentedComment #4
megan_m commentedI can confirm that this patch applies, gets rid of the ajax error, and makes the modal display using the correct form mode.
Comment #5
megan_m commentedSorry, thought I found an issue but it was a configuration problem on my part.
Comment #6
avpadernoComment #7
tamerzg commented