Skip to content

Commit 2e75105

Browse files
authored
add role attribute to honeypot field (#339)
1 parent 18b8ce2 commit 2e75105

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

UPGRADE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Upgrade Notes
22

3-
#### Update to Version 4.1.2
3+
## Version 4.1.2
44
- **[BUGFIX]**: Email CSV export: delete unnecessary line to prevent out of memory issues. [#328](https://github.com/dachcom-digital/pimcore-formbuilder/pull/328)
5+
- **[ENHANCEMENT]**: Add `role="presentation"` to honeypot. [#333](https://github.com/dachcom-digital/pimcore-formbuilder/issues/333)
56

67
## Version 4.1.1
78
- **[BUGFIX]**: Fix legacy fine uploader identifier

docs/03_SpamProtection.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ form_builder:
88
spam_protection:
99
honeypot:
1010
field_name: 'inputUserName' # this is the default value
11-
enable_inline_style: true # ths is the default value
11+
enable_inline_style: true # this is the default value
12+
enable_role_attribute: true # this is the default value and will add the role="presentation" attribute
1213
```
1314
1415
***

src/FormBuilderBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ private function buildSpamProductionNode(): NodeDefinition
605605
->children()
606606
->scalarNode('field_name')->defaultValue('inputUserName')->end()
607607
->booleanNode('enable_inline_style')->defaultTrue()->end()
608+
->booleanNode('enable_role_attribute')->defaultTrue()->end()
608609
->end()
609610
->end()
610611
->arrayNode('recaptcha_v3')

src/FormBuilderBundle/Form/Type/HoneypotType.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ public function configureOptions(OptionsResolver $resolver): void
2323
$config = $this->configuration->getConfig('spam_protection');
2424
$honeyPotConfig = $config['honeypot'];
2525

26+
$attributes = [
27+
'autocomplete' => 'off',
28+
'tabindex' => -1,
29+
'style' => $honeyPotConfig['enable_inline_style'] === true ? 'position: absolute; left: -500%; top: -500%;' : ''
30+
];
31+
32+
if ($honeyPotConfig['enable_role_attribute'] === true) {
33+
$attributes['role'] = 'presentation';
34+
}
35+
2636
$resolver->setDefaults([
2737
'required' => false,
2838
'mapped' => false,
2939
'data' => '',
30-
'attr' => [
31-
'autocomplete' => 'off',
32-
'tabindex' => -1,
33-
'style' => $honeyPotConfig['enable_inline_style'] === true ? 'position: absolute; left: -500%; top: -500%;' : ''
34-
],
40+
'attr' => $attributes,
3541
'constraints' => [
3642
new Blank(
3743
[

0 commit comments

Comments
 (0)