This bundle adds into each form a hidden field with an empty value. If the field comes back with a non-empty value, then we assume that the form was filled in by a bot and the form is rejected.
Open a command console, enter your project directory and execute:
$ composer require meteo-concept/hiddenfieldantispam-bundle
Install the bundle with one of the commands above. You now have to enable it and configure it without the recipe.
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php
return [
// ...
MeteoConcept\HiddenFieldAntispamBundle\MeteoConceptHiddenFieldAntispamBundle::class => ['all' => true],
];
Configure the bundle, for instance in
config/packages/meteo_concept_hidden_field_antispam.yml
:
meteo_concept_hidden_field_antispam:
enabled: true # this is the default
field_name: "meteo_concept_sentinel" # this is the default
twig:
form_themes:
- '@MeteoConceptHiddenFieldAntispam/hidden_field_antispam_form.html.twig' # to hide the antispam field
You have nothing else to do, the field is automatically added to all root (i.e. non-embedded forms).
- Randomize the field name, just in case bots would become smart
- More advanced, randomize the field type while leaving it invisible