Problem/Motivation

When rendering a custom form for an existing user without the username or email fields it still alters the form and effectively adds the name in but with just type=>value and it then tries to save a null against the user and crashes.

Steps to reproduce

Create new view mode for user entity
Only add as an example, a custom field on it, such as address
Create custom form route to display user with that new form view mode
Attempt to save the form
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Proposed resolution

Only adjust form elements that exist in the entity form

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

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

Driskell created an issue. See original summary.

driskell’s picture

Status: Active » Needs review
anybody’s picture

Version: 8.x-1.2 » 8.x-1.x-dev

Failing tests are unrelated, also fail in dev.

anybody’s picture

Assigned: Unassigned » grevil

@Grevil: To me this change looks absolutely reasonable as a safety net. Can you see any possible side-effects? Otherwise I'd vote to merge this in?

RTBC+1 from my side. I see that case.

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

grevil’s picture

Status: Needs review » Reviewed & tested by the community

Yea LGTM! RTBC!

grevil’s picture

Merged. Thanks @Driskell!

grevil’s picture

Assigned: grevil » Unassigned
Status: Reviewed & tested by the community » Fixed

  • Grevil committed a4281410 on 8.x-1.x authored by Driskell
    Issue #3318717: Custom user entity forms crash when module is enabled if...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.