-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom setForm() method for ConfirmedPasswordField #10239
Conversation
Fixes bug that makes it impossible to set a ConfirmedPasswordField as "required" due to the two child fields not getting a form assigned.
@purplespider so does |
@dhensby Correct. Just Not sure how to achieve this though. I noticed that when the form is rendered, Also worth noting that Are you aware of any other field types that consist of multiple child fields? |
The I'm pretty shocked that you can't do |
Sorry Dan, yeh you're right. I've run some tests on a fresh Silverstripe install, and it does half work: When using
However:
|
Ok, makes sense - so with this fix and using The alternative is to find a way for the nested password fields to see their "parent's" required state, but I'm not sure there's any reference to do that? It looks like it won't and we would need to update the |
Nope. This fix plus It looks to me like the two "child" fields are effectively added to the form field list, so there is no concept of the parent |
I remember having all kinds of trouble around these fields in the past because they just aren't built quite right. As you say, they don't really have a way to know they are required because I don't think there's really a way to set requiredfields to know that all children should be required if the parent "wrapping" field is. I wonder if we either need to update https://github.com/silverstripe/silverstripe-framework/blob/4/src/Forms/RequiredFields.php#L204-L207 or updated |
Closed in favour of #11099 |
Fixes bug that makes it impossible to set a ConfirmedPasswordField as "required" due to the two child fields not getting a form assigned to them.
Issue
Adding the names of a
ConfirmedPasswordField
field to aRequiredFields
form validator would have no effect. e.g. The fields would not be marked asrequired
.This is because the standard
setForm()
method inFormField
sets the form on the parentConfirmedPasswordField
but not on either the two childPasswordField
s.Fix
This PR adds a custom
setForm()
method toConfirmedPasswordField
which sets the form on the child fields as well as the parent. So the following validator will now work as expected: