add captcha

This commit is contained in:
Simon Vieille 2022-05-29 21:04:28 +02:00
parent e2e8e2ed79
commit eedfb4c9f2
Signed by: deblan
GPG Key ID: 579388D585F70417
7 changed files with 67 additions and 1 deletions

View File

@ -109,6 +109,35 @@ pre[class*="language-"] {
textarea {
border-radius: 10px;
}
&-captcha {
label {
display: block;
}
img {
vertical-align: middle;
margin-right: 10px;
border-radius: 10px;
width: auto;
}
input {
display: inline-block;
width: 100px !important;
height: 50px !important;
margin-bottom: -1px;
}
.form-error-icon {
display: none;
}
.form-error-message {
display: block;
color: red;
}
}
}
.button, .btn, input[type="submit"], input[type="button"] {

View File

@ -7,6 +7,7 @@
"php": ">=8.0.0",
"beberlei/doctrineextensions": "^1.3",
"friendsofsymfony/jsrouting-bundle": "^2.7",
"gregwar/captcha-bundle": "^2.2",
"knplabs/knp-markdown-bundle": "^1.9",
"knplabs/knp-menu-bundle": "^3.1",
"murph/murph-core": "dev-master"

View File

@ -24,4 +24,5 @@ return [
Knp\DoctrineBehaviors\DoctrineBehaviorsBundle::class => ['all' => true],
SPE\FilesizeExtensionBundle\SPEFilesizeExtensionBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true],
];

View File

@ -15,6 +15,7 @@ use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Url;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Gregwar\CaptchaBundle\Type\CaptchaType;
class UserCommentType extends AbstractType
{
@ -86,6 +87,19 @@ class UserCommentType extends AbstractType
]
);
$builder->add(
'captcha',
CaptchaType::class,
[
'invalid_message' => 'Code invalide',
'label' => 'Captcha',
'max_front_lines' => 1,
'width' => 140,
'height' => 50,
'length' => 3,
]
);
$builder->add(
'parentCommentId',
HiddenType::class,

View File

@ -10,6 +10,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Gregwar\CaptchaBundle\Type\CaptchaType;
class ContactType extends AbstractType
{
@ -71,6 +72,19 @@ class ContactType extends AbstractType
],
]
);
$builder->add(
'captcha',
CaptchaType::class,
[
'invalid_message' => 'Code invalide',
'label' => 'Captcha',
'max_front_lines' => 1,
'width' => 140,
'height' => 50,
'length' => 3,
]
);
}
public function configureOptions(OptionsResolver $resolver)

View File

@ -36,6 +36,10 @@
{{ form_errors(form.message) }}
{{ form_widget(form.message, {attr: {cols: 30, rows: 10}}) }}
</div>
<div class="field field-captcha">
{{ form_label(form.captcha) }}
{{ form_widget(form.captcha) }}
</div>
<div class="field">
<input type="checkbox" id="rgpd" required>
<label for="rgpd">En validant ce formulaire, vous acceptez que j'utilise votre e-mail pour vous fournir une réponse.</label>

View File

@ -180,7 +180,10 @@
</div>
</div>
</div>
<div class="field field-captcha">
{{ form_label(form.captcha) }}
{{ form_widget(form.captcha) }}
</div>
<div class="field">
<input type="checkbox" id="rgpd" required>
<label for="rgpd">En validant ce formulaire, vous acceptez que les données saisies seront publiées sur cette page à l'exception de votre e-mail. Votre e-mail sera utilisé pour afficher votre avatar (<a href="https://www.libravatar.org/" target="_blank">via Libravatar</a>) et pour les notifications.</label>