Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
C
captcha
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Drupal.org issue queue
Drupal.org issue queue
Security & Compliance
Security & Compliance
Dependency List
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
project
captcha
Commits
483780b9
Commit
483780b9
authored
Apr 17, 2018
by
Prashant.c
Committed by
elachlan
Apr 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2839891
by DuaelFr, Prashant.c: Allow to target the base_form_id
parent
746636da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
captcha.module
captcha.module
+15
-0
src/Form/CaptchaPointForm.php
src/Form/CaptchaPointForm.php
+1
-0
No files found.
captcha.module
View file @
483780b9
...
...
@@ -18,6 +18,7 @@ use Drupal\Core\Render\Markup;
use
Drupal\Core\Routing\RouteMatchInterface
;
use
Drupal\Core\Url
;
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Form\BaseFormIdInterface
;
/**
* Constants for CAPTCHA persistence.
...
...
@@ -47,6 +48,7 @@ define('CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE', 1);
// Default captcha field access.
define
(
'CAPTCHA_FIELD_DEFAULT_ACCESS'
,
1
);
/**
* Implements hook_help().
*/
...
...
@@ -167,6 +169,19 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
->
getStorage
(
'captcha_point'
)
->
load
(
$form_id
);
// If there is no CaptchaPoint for the form_id, try to use the base_form_id.
if
(
!
$captcha_point
||
!
$captcha_point
->
status
())
{
$form_object
=
$form_state
->
getFormObject
();
if
(
$form_object
instanceof
BaseFormIdInterface
)
{
$base_form_id
=
$form_object
->
getBaseFormId
();
if
(
!
empty
(
$base_form_id
)
&&
$base_form_id
!=
$form_id
)
{
$captcha_point
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'captcha_point'
)
->
load
(
$base_form_id
);
}
}
}
if
(
!
$captcha_point
&&
$config
->
get
(
'enabled_default'
))
{
// Create fake captcha point without saving.
$captcha_point
=
new
CaptchaPoint
([
...
...
src/Form/CaptchaPointForm.php
View file @
483780b9
...
...
@@ -64,6 +64,7 @@ class CaptchaPointForm extends EntityForm {
$form
[
'label'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'Form ID'
),
'#description'
=>
$this
->
t
(
'Also works with the base form ID.'
),
'#default_value'
=>
$captcha_point
->
label
(),
'#required'
=>
TRUE
,
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment