Skip to content

Commit 7a02b54

Browse files
committed
Updated RecaptchaType
1 parent 61ba5da commit 7a02b54

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Bridge/Form/Extension/RecaptchaExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Silex\Application;
66
use Symfony\Component\Form\AbstractExtension;
7-
use EWZ\Bundle\RecaptchaBundle\Form\Type\RecaptchaType;
7+
use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
88

99
/**
1010
* Extends form to register captcha type
@@ -36,7 +36,7 @@ public function __construct(Application $app)
3636
protected function loadTypes()
3737
{
3838
return array(
39-
new RecaptchaType(
39+
new EWZRecaptchaType(
4040
$this->app['ewz_recaptcha.public_key'],
4141
$this->app['ewz_recaptcha.enabled'],
4242
$this->app['ewz_recaptcha.ajax'],

Form/Type/RecaptchaType.php Form/Type/EWZRecaptchaType.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
namespace EWZ\Bundle\RecaptchaBundle\Form\Type;
4-
4+
use Symfony\Component\Form\Extension\Core\Type\TextType;
55
use Symfony\Component\Form\FormInterface;
66
use Symfony\Component\Form\FormView;
77
use Symfony\Component\Form\AbstractType;
@@ -10,7 +10,7 @@
1010
/**
1111
* A field for entering a recaptcha text.
1212
*/
13-
class RecaptchaType extends AbstractType
13+
class EWZRecaptchaType extends AbstractType
1414
{
1515
/**
1616
* The reCAPTCHA server URL's
@@ -118,7 +118,7 @@ public function configureOptions(OptionsResolver $resolver)
118118
*/
119119
public function getParent()
120120
{
121-
return 'form';
121+
return TextType::class;
122122
}
123123

124124
/**

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ When creating a new form class add the following line to create the field:
107107
public function buildForm(FormBuilder $builder, array $options)
108108
{
109109
// ...
110-
$builder->add('recaptcha', 'ewz_recaptcha');
110+
$builder->add('recaptcha', EWZRecaptchaType::class);
111111
// ...
112112
}
113113
```
@@ -120,7 +120,7 @@ You can pass extra options to reCAPTCHA with the "attr > options" option:
120120
public function buildForm(FormBuilder $builder, array $options)
121121
{
122122
// ...
123-
$builder->add('recaptcha', 'ewz_recaptcha', array(
123+
$builder->add('recaptcha', EWZRecaptchaType::class, array(
124124
'attr' => array(
125125
'options' => array(
126126
'theme' => 'light',
@@ -157,7 +157,7 @@ use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
157157
public function buildForm(FormBuilder $builder, array $options)
158158
{
159159
// ...
160-
$builder->add('recaptcha', 'ewz_recaptcha', array(
160+
$builder->add('recaptcha', EWZRecaptchaType::class, array(
161161
'attr' => array(
162162
'options' => array(
163163
'theme' => 'light',
@@ -213,7 +213,7 @@ using JavaScript:
213213
<div id="recaptcha-container"></div>
214214
<script type="text/javascript">
215215
$(document).ready(function() {
216-
$.getScript("<?php echo \EWZ\Bundle\RecaptchaBundle\Form\Type\RecaptchaType::RECAPTCHA_API_JS_SERVER ?>", function() {
216+
$.getScript("<?php echo \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::RECAPTCHA_API_JS_SERVER ?>", function() {
217217
Recaptcha.create("<?php echo $form['recaptcha']->get('public_key') ?>", "recaptcha-container", {
218218
theme: "clean",
219219
});
@@ -228,7 +228,7 @@ using JavaScript:
228228
<div id="recaptcha-container"></div>
229229
<script type="text/javascript">
230230
$(document).ready(function() {
231-
$.getScript("{{ constant('\\EWZ\\Bundle\\RecaptchaBundle\\Form\\Type\\RecaptchaType::RECAPTCHA_API_JS_SERVER') }}", function() {
231+
$.getScript("{{ constant('\\EWZ\\Bundle\\RecaptchaBundle\\Form\\Type\\EWZRecaptchaType::RECAPTCHA_API_JS_SERVER') }}", function() {
232232
Recaptcha.create("{{ form.recaptcha.get('public_key') }}", "recaptcha-container", {
233233
theme: "clean"
234234
});

Resources/config/services.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
services:
22
ewz_recaptcha.form.type:
3-
class: EWZ\Bundle\RecaptchaBundle\Form\Type\RecaptchaType
3+
class: EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType
44
arguments:
55
- '%ewz_recaptcha.public_key%'
66
- '%ewz_recaptcha.enabled%'
77
- '%ewz_recaptcha.ajax%'
88
- '%ewz_recaptcha.locale_key%'
99
tags:
10-
- { name: form.type, alias: ewz_recaptcha }
10+
- { name: form.type }
1111

1212
ewz_recaptcha.validator.true:
1313
class: EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueValidator

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"autoload": {
1919
"psr-4": { "EWZ\\Bundle\\RecaptchaBundle\\": "" }
2020
}
21-
}
21+
}

0 commit comments

Comments
 (0)