Problem/Motivation
When you need to display Default User form programmatically (for example, in some block on page), it causes the error:
Error: Call to a member function id() on null in force_password_change_form_alter() (line 106 of modules/contrib/force_password_change/force_password_change.module)
Because, it gets an account object from the Route, not from Form State.
Steps to reproduce
1. Install the module and enable it.
2. Create custom block and display User Default form programmatically.
$formObject = $this->entityTypeManager->getFormObject('user', 'default')->setEntity($user);
$form = $this->formBuilder->getForm($formObject);
3. Add the block to some custom page, where url not uses User ID.
Comments
Comment #2
allaprishchepa commentedHere is a patch.
Comment #3
allaprishchepa commentedPatch is updated.
Because error appears also in validate function.
Comment #4
allaprishchepa commentedComment #5
larisse commentedThis still a problem in 2.0.x version?
Comment #6
mistrae commentedI use the 2.0 version and patch is needed, yes.
Comment #7
larisse commentedComment #8
larisse commentedI'll take a look on this.
Comment #9
larisse commentedComment #10
larisse commentedComment #12
larisse commentedI committed in 2.0.x branch and will release a new version soon.
Thanks to everyone for working on this!