Problem/Motivation
Marking as task since I can't decide if this is a bug report or a feature request.
My use case is that we have forms that get built by a form alter of a different module, in my case that's ECA. And because the form alter of ECA gets called later than the form alter of captcha, the form doesn't have any submit buttons yet and therefore captcha doesn't insert the widget.
However, the method $captchaService->insertCaptchaElement is written in a way that the second argument for the placement can be NULL and the insertion still works.
Proposed resolution
Call the insert function even if placement is NULL.
Issue fork captcha-3507522
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jurgenhaasComment #5
anybodyThanks @jurgenhaas - how sure are we, that this doesn't introduce any unwanted side-effects? Generally I'd be fine with this change, but I'm not really sure about possible edge-cases, especially in existing installations.
Comment #6
jurgenhaasI'm pretty certain. Here is why:
$captchaService->insertCaptchaElementis explicitly built to allow for a NULL placement. That must have been done on purpose.So, what's the risk that I'm wrong? Well, if there is an unintended side-effect, it could only be on forms with no buttons. Do they exist and why? I think, chances are negligible.
Comment #7
anybodyThanks for your feedback @jurgenhaas. I agree the risks are low enough, the benefit is much higher. Let's merge this.
Comment #8
anybody