-
-
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
Afform - Add support for ReCaptcha v2 #24860
Conversation
(Standard links)
|
76c39e4
to
7a22510
Compare
This seems like the right direction to me I'm just wondering @colemanw if its worth splitting out the work on the general afform type from the recaptcha work just to try and make things a little mergeable? |
Ok I've broken the Afform part into #24862 |
7a22510
to
434d65c
Compare
Thanks @kurund. I've merged the other PR, rebased this one, and fixed the bug you noticed. I think this is done. As a followup, I noticed that the validation errors (including this one) don't bubble all the way up to actually get shown to the user. I think we'll need to extend the |
Yes, it's working as expected now.
I feel CRM_Core_Exception is not passing the errorData correctly. So we might directly need to return the error message. diff --git a/ext/afform/core/Civi/Api4/Action/Afform/Submit.php b/ext/afform/core/Civi/Api4/Action/Afform/Submit.php
index f9c301cb1b..e2c64b1c37 100644
--- a/ext/afform/core/Civi/Api4/Action/Afform/Submit.php
+++ b/ext/afform/core/Civi/Api4/Action/Afform/Submit.php
@@ -67,8 +67,10 @@ class Submit extends AbstractProcessor {
$event = new AfformValidateEvent($this->_afform, $this->_formDataModel, $this, $entityValues);
\Civi::dispatcher()->dispatch('civi.afform.validate', $event);
$errors = $event->getErrors();
+ $detailedErrors = implode('<br/>', $errors);
+
if ($errors) {
- throw new \CRM_Core_Exception(ts('Validation Error', ['plural' => '%1 Validation Errors', 'count' => count($errors)]), 0, ['validation' => $errors]);
+ throw new \CRM_Core_Exception($detailedErrors);
}
I also think |
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.
Good merge after test fixes. We can handle the sever error message display separately if you don't agree with the above suggestion.
Fixes dev/core#3173 Co-authored-by: Coleman Watts <[email protected]>
434d65c
to
45293ec
Compare
@kurund the reason I'm putting errors as an array is because concatenating html with plain text into a string leads to escaping issues. Better to output the array of errors and let the javascript template render the markup. |
Overview
Supports the Recapta2 element in FormBuilder.
Technical Details
Depends on #24862 for Afform to support extensions adding new element types.
Comments
This refactors #24689, moving the code to an extension and making it event-driven.