If you create a password_confirm field on a form where there is no user object attached (for example, registration during checkout), the password policy tries to attach itself to that form. However the Ajax callbacks fail as there is nowhere for the password policy status to appear.
If you try to add the wrapper so that the callback has something to replace, it continues to fail, because there is no user object to check against.
A simple solution to this is to only apply the Ajax callback to a form/element if the entity on the form is an instance of UserInterface. At the very least, it should ensure that the entity has the methods it needs on it.
There are more robust solutions out there for a wider range of use cases, but this is a small simple patch that should do the basics.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | interdiff.txt | 1.12 KB | tatarbj |
| #3 | password_policy-depend-on-user-object-2941329-3.patch | 1.79 KB | tatarbj |
| #2 | password-policy_depend-on-user-object.patch | 1.69 KB | sophie.sk |
Comments
Comment #2
sophie.skInitial patch attached.
Comment #3
tatarbjI've tested the proposed way to tackle this issue and i think there is no better and more elegant one - i've just fixed some small issues with it to make it php7 complaint too.
It's ready to merge after some further tests if you wish @nerdstein!
Bests,
Balazs.
Comment #4
nerdsteinThis looks good, merging - thanks all