-
-
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 JQuery Validation for radios #17937
Conversation
(Standard links)
|
6d3ef34
to
00e7a4a
Compare
Fix layout of required radio message
00e7a4a
to
dd28351
Compare
@@ -366,6 +366,9 @@ public function &add( | |||
$type, $name, $label = '', | |||
$attributes = '', $required = FALSE, $extra = NULL | |||
) { | |||
if ($type === 'radio') { | |||
CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_Form::addRadio'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this in because at the moment CRM_Core_Form::add 's function declaration makes no sense for radios better to use the addRadio function instead
Tested and overall this works. I was wondering if it's just radios that need this, so I also checked checkboxes. It works but behaves differently with stripe vs not stripe, but I'm not sure if that's a flaw in jquery validate? With stripe (which I assume is using jquery validate), you have to check all the checkboxes. With not-stripe, required just means you have to pick at least one checkbox, which matches what I'd expect. |
this is very form layer so I think it's OK without test. My take on this is that it is mergeable but that perhaps there is more that should be considered. Adding merge-ready to give @seamuslee001 & @demeritcowboy space to loop back in on the last comment |
@demeritcowboy Stripe currently loads in some overrides for jquery validate to make it work properly without modifying CiviCRM core. This should be tested using the following in the browser console (without stripe loaded): I may well need to update the Stripe code to remove some of the overrides once this is merged. That's a good thing because we'll have more consistency and less need to hack around stuff :-) |
@mattwire does this mean we should remove merge-ready? |
I'd like either @seamuslee001 or @demeritcowboy to do a quick test with the commands I've put up but I'm happy for this to be "merge ready" as if it does trigger any issues they are likely to be less than what there was before and we can work through to resolve those too. When I started looking at the jquery validation stuff we were in a pretty bad place with Civi, thanks to that initial work and then the work that @seamuslee001 has been doing we're really getting somewhere |
Ok thanks that probably explains the stripe part. I'm good. |
Merging based on discussion and @demeritcowboy |
Just noting this has caused an (unreleased) regression - https://lab.civicrm.org/dev/core/-/issues/1928#note_41814 |
Overview
This fixes the jQuery validation for radio html objects by ensuring that the required attribute is properly set on radio html objects and that the error message is correctly placed
Before
CRM.$('#Main').valid();
After
Repeat Steps 1-4 as above but in step 5 you should find that for the radio field there is a new message that it is a required field sitting next to the radios
ping @demeritcowboy @mattwire @colemanw