- Issue created by @sjpagan
Problem/Motivation
When trying to create a user entity using Inline Entity Form (IEF) inside an Entity Browser modal (e.g. through a field like account referencing a user), the form does not render the required name (username) field.
As a result, the user entity is submitted without a username, which causes a fatal SQL error due to the NOT NULL constraint on the name base field in the user entity schema.
This makes it impossible to create user entities from an IEF context unless a workaround is implemented manually.
MySQL error encountered:
sql
Copy
Edit
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null: INSERT INTO "lowfly_users_field_data" (...) VALUES (..., NULL, ...) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 816 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Steps to reproduce
Create a user reference field (e.g. called account) on a Profile or content entity.
Configure the field widget as “Inline Entity Form – Complex”.
Enable Entity Browser to allow modal creation of users through that field.
Open the form and attempt to create a new user via the modal.
Submit the form without the name field being present.
Expected: The user is created successfully with all required fields.
Actual: The name field is missing and the save operation fails due to a NULL username.
Proposed resolution
Ensure that when creating a user entity via IEF, all required base fields like name are included in the embedded form. This may require ensuring form display configurations are respected or implementing fallback logic to include mandatory fields.
Remaining tasks
Reproduce the issue on a fresh Drupal 11 site.
Confirm whether this is caused by IEF or the user form mode used.
Propose a patch or workaround.
Write test coverage if needed.
User interface changes
The username (name) field should appear when creating a user entity in an IEF context.
API changes
None expected.
Data model changes
None.
Active
2.13
Widget selector plugins