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

Fix validation of select2 fields in "On behalf of Organisation" block #17672

Merged
merged 2 commits into from
Jun 20, 2020

Conversation

mattwire
Copy link
Contributor

Overview

Found by @jmcclelland via https://lab.civicrm.org/extensions/stripe/-/issues/147#note_38994

Normally a select2 is a hidden select field with another visible "text" field. But it is the hidden select2 field that actually needs validating so we ignore (following #16488) using jquery validate and the pattern hidden:not(.select2). This fails for the "I want to contribution on behalf of organisation" block because the select2 fields get hidden by the parent div and are not required when the block is hidden - but they are required when the block is visible.

Before

Form validation fails if you have "on behalf of organisation" option on the form and one of those fields is a select2.

After

Form validation fails if you have "on behalf of organisation" option checked on the form and one of those fields is a select2 but passes if you don't have the option checked

Technical Details

We introduce a new "crm-no-validate" class for jquery validate to ignore. Then we apply that to the select2 fields when hiding the "On behalf of" block.

Comments

The first commit is just whitespace cleanup. Please review the second commit to see the changes made.

@civibot
Copy link

civibot bot commented Jun 20, 2020

(Standard links)

@seamuslee001
Copy link
Contributor

Once the indentation fix is sorted then this PR is fine code works

@eileenmcnaughton
Copy link
Contributor

Looks like this caused https://lab.civicrm.org/dev/core/-/issues/1941 - just investigating now

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

Successfully merging this pull request may close these issues.

3 participants