Skip to content
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

Member form validator doesn't work #11357

Closed
2 tasks done
mfendeksilverstripe opened this issue Sep 2, 2024 · 1 comment
Closed
2 tasks done

Member form validator doesn't work #11357

mfendeksilverstripe opened this issue Sep 2, 2024 · 1 comment

Comments

@mfendeksilverstripe
Copy link
Contributor

mfendeksilverstripe commented Sep 2, 2024

Module version(s) affected

5.2.22

Description

The form validator for Member edit form doesn't seem to work. This is likely a regression caused by CMS 5 upgrade. Possibly related to the introduction of getCMSCompositeValidator().

How to reproduce

  • navigate to the Security section of the CMS
  • click on the add new member button
  • you should see member edit form which is empty, do not input anything into the form
  • click save

Expected behaviour:

I expect to see validation message for at least FirstName and Email as defined in Member_Validator as those two fields are required.

Screenshot 2024-09-02 at 12 56 16 PM

Actual behaviour:

I don't see any validation message and the new user gets created with empty form fields.

Screenshot 2024-09-02 at 1 25 46 PM

Possible Solution

Manually adding the member validator to the composite validator remedies the issue:

class MemberValidatorExtension extends Extension
{
    /**
     * Extension point in @see Member::getCMSCompositeValidator()
     *
     * @param CompositeValidator $compositeValidator
     * @return void
     */
    public function updateCMSCompositeValidator(CompositeValidator $compositeValidator): void
    {
        $owner = $this->getOwner();
        $memberValidator = $owner->getValidator();

        $compositeValidator->addValidator($memberValidator);
    }
}

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants