-
-
Notifications
You must be signed in to change notification settings - Fork 825
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 implementation of jQuery.validate #16495
Conversation
(Standard links)
|
d393f33
to
e54e844
Compare
@mattwire can you rebase this please |
e54e844
to
374f3dd
Compare
Thanks @seamuslee001 rebased. Note that I found something similar here https://github.com/coopsymbiotic/coop.symbiotic.symbioticux/blob/master/templates/CRM/Symbioticux/Contribute/Form/Contribution/Main.validate.tpl so would be great if @mlutfy was able to comment on this PR. Also note that originally I added in |
I have to admit I don't really remember why that file was forked in symbioticux some time ago. It may have been to remove the alerts, or add CSS classes, although I've noticed a few times that select2 fields were not correctly validated before submit, and that can be a huge annoyance. The code seems OK, but I have to admit that I'm not the most qualified to comment here. @colemanw ? Also added sig:interface because this might have an impact on the CSS of existing sites? |
I think this all looks good to me haven't r-run it yet tho |
@mattwire are you able to rebase this please. |
374f3dd
to
f911204
Compare
@seamuslee001 Thanks - now rebased |
…M settings, validates select2 fields and uses Civi/bootstrap classes for errors
f911204
to
b260c30
Compare
@seamuslee001 @colemanw I've updated based on comments and think this is now ok to merge? |
Betty and I are reviewing PR's and we came across this one. We are struggling with testing this PR. We checked a contribution page and the javascript Also when we press review your contribution we get different error messages then in the screenshot provided by after. See our screenshot |
@jaapjansma Sorry for not explaining better :-) Currently there is another problem with the CiviCRM forms that means they don't get detected by jQuery validate - that will be fixed in #16488 but it is not yet ready. I have added above in the PR description some more information. |
(tested on 5.26 buildkit) I ran this by looking at a contribution form as anon user and clicking submit. Fields lit up as errors. I added The conditional pass is that:
|
So basically this PR is not yet ready for review that is what I understand. |
@jaapjansma We have been shipping the same thing (via an override) in Stripe for a long time. The PR, in my opinion, is ready for review and merge because it improves the form validation. But we need to follow up with additional PRs to make further changes. |
@eileenmcnaughton @colemanw what do you think? Betty and I have reviewed it on March 23 and @artfulrobot on May 26th. So I would say you should have a call on this whether this could be merged or not as we are not able to review it any further. |
#16488 is a much bigger change - it actually changes the way the form fields are rendered (so validation will behave differently). This PR (#16495) does not depend on #16488 as it is a frontend-only (javascript) change which improves the way validation works on the form if it has the right information (and that information will come from a version of #16488). So we need to review/merge this one before we can work on #16488 (#16488 has a much bigger chance to break things..) |
@colemanw will have to be the final merger on this one as those are very central js functions and I don't feel able to assess whether all the implications of touching them have been addressed in the review |
@colemanw are you able to check this one for final merge? |
Merged via #16488 |
Overview
Fix implementation of jQuery validate in CiviCRM so that it actually uses the CRM settings, validates select2 fields and uses Civi/bootstrap classes for errors.
Partial from #16488
Before
jQuery validate in CiviCRM did not work with select2. In Common.js there was code to load CiviCRM specific settings but they weren't actually being loaded!
After
select2 is validated (note that the error message is currently the label - that could be improved as could the positioning of some of the error messages - that's all possible but out of scope for this PR!):
Technical Details
If the PR involves technical details/changes/considerations which would not be manifest to a casual developer skimming the above sections, please describe the details here.
Comments
Testing
For testing you can do in the browser console on a contribution page:
var validator = CRM.$('#Main').validate();
validator.settings
- to show the settings that are loaded for the page.CRM.$('#Main').valid();
to check if the form is "valid" - returns true/false.Currently this will return valid for many required fields on the form if they are empty. This is because CiviCRM is not setting them as required before creating the form - that will be fixed in #16488.
So to test you have to add the class "required" to the form fields once the page has loaded:
This is particularly a problem for any processor that has "billing address" fields.