Problem/Motivation
Currently, when using image_captcha/Image captcha type, it works perfectly fine inside added captcha points. But if we would like to use it inside a form, the refresh button is missing.
The reason is the following:
If we render the image captcha inside a captcha point, we first render the generel captcha data with our image_captcha data given to the captcha.html.twig. Once this is done, we use "image_captcha_element_info_alter" in our image_captcha module to post process our form and add the refresh button, to the form.
Unfortunately, this post-processing won't take place if we insert a captcha form element inside a form via '#type' => 'captcha'
and therefore the refresh button is missing.
Steps to reproduce
Add:
$form['test'] = [
'#type' => 'captcha',
'#captcha_type' => 'image_captcha/Image',
'#captcha_admin_mode' => TRUE,
];
Inside a test form and check the output.
Proposed resolution
Implement something like "$captcha['post_process']" inside "hook_captcha_captcha" to let submodules register form postprocessing inside their custom captcha's "hook_captcha_captcha".
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork captcha-3326503
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 #2
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedComment #3
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedComment #4
AnybodyYes, please fix this and add tests to ensure it doesn't break again.
Comment #6
AnybodyTest fail.
Comment #7
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedComment #8
AnybodyThe test should be working, otherwise we're doing something wrong here.
Please have a look at the test form output manually.
Comment #9
AnybodySuper nice cleanup BTW @Grevil! Thx :)
It's worth to fix this clean finally. Good job.
Comment #10
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedAll fixed, please review once again!
Comment #11
Anybody2 fail?
Comment #12
AnybodySuuper nice @Grevil! Just some last comments added. Then this is RTBC! :)
Comment #13
Anybody1 unresolved.
Comment #14
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commentedDone! Let's see if all tests succeed!
Comment #15
AnybodyAll green! Yay :) RTBC!
Comment #17
Grevil CreditAttribution: Grevil as a volunteer and at DROWL.de commented