Skip to content
Browse files

captcha gd, removed the position option

  • Loading branch information...
1 parent 4c38534 commit 64b7d3354f21e585783457c6f7fa1ab9f05e2ead @bamarni bamarni committed Sep 5, 2012
View
1 DependencyInjection/Configuration.php
@@ -64,7 +64,6 @@ private function addCaptcha(ArrayNodeDefinition $rootNode)
->children()
->booleanNode('enabled')->defaultTrue()->end()
->scalarNode('driver')->defaultValue('gd')->end()
- ->scalarNode('position')->defaultValue('left')->end()
->scalarNode('width')->defaultValue(100)->end()
->scalarNode('height')->defaultValue(30)->end()
->scalarNode('length')->defaultValue(4)->end()
View
25 Form/Core/Type/CaptchaType.php
@@ -15,6 +15,7 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Genemu\Bundle\FormBundle\Gd\Type\Captcha;
use Genemu\Bundle\FormBundle\Form\Core\Validator\CaptchaValidator;
@@ -48,24 +49,19 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$this->captcha->setOptions($options);
- $builder
- ->addValidator(new CaptchaValidator($this->captcha))
- ->setAttribute('captcha', $this->captcha)
- ->setAttribute('format', $options['format'])
- ->setAttribute('position', $options['position']);
+ $builder->addValidator(new CaptchaValidator($this->captcha));
}
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
- $captcha = $form->getAttribute('captcha');
+ $captcha = $this->captcha;
$view->vars = array_replace($view->vars, array(
'value' => '',
- 'position' => $form->getAttribute('position'),
- 'src' => $captcha->getBase64($form->getAttribute('format')),
+ 'src' => $captcha->getBase64($options['format']),
'width' => $captcha->getWidth(),
'height' => $captcha->getHeight(),
));
@@ -74,13 +70,14 @@ public function buildView(FormView $view, FormInterface $form, array $options)
/**
* {@inheritdoc}
*/
- public function getDefaultOptions(array $options)
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- return array_merge(array(
- 'attr' => array(
- 'autocomplete' => 'off'
- )
- ), $this->options);
+ $defaults = array_merge(
+ array('attr' => array('autocomplete' => 'off')),
+ $this->options
+ );
+
+ $resolver->setDefaults($defaults);
}
/**
View
1 Resources/doc/captcha_gd/default.md
@@ -8,7 +8,6 @@ genemu_form:
width: 100
height: 40
length: 4
- position: 'left'
format: 'png'
chars: '0123456789'
font_size: 18
View
11 Resources/views/Form/div_layout.html.twig
@@ -1,14 +1,9 @@
{% block genemu_captcha_widget %}
{% spaceless %}
- {% if position == "left" %}
- <img src="{{ src }}" width="{{ width }}" height="{{ height }}" title="{{ name|trans }}" />
- {{ block("field_widget") }}
- {% else %}
- {{ block("field_widget") }}
- <img src="{{ src }}" width="{{ width }}" height="{{ height }}" title="{{ name|trans }}" />
- {% endif %}
+ <img src="{{ src }}" width="{{ width }}" height="{{ height }}" title="{{ name|trans }}" />
+ {{ block("field_widget") }}
{% endspaceless %}
-{% endblock genemu_captcha_widget %}
+{% endblock %}
{% block genemu_recaptcha_widget %}
{% spaceless %}
View
8 UPGRADE 2.1.md
@@ -3,7 +3,7 @@ UPGRADE to Symfony 2.1
### JQuery Chosen
-[BC BREAK] Widget option cannot specify the choice type anymore, you have to append the widget in the type name instead :
+Widget option cannot specify the choice type anymore, you have to append the widget in the type name instead :
Before :
``` php
@@ -23,7 +23,7 @@ Same instructions than Chosen.
### Routing
-[BC BREAK] Routing is defined in xml files instead of annotations (to remove the depency with SensioFrameworkExtraBundle)
+Routing is defined in xml files instead of annotations (to remove the depency with SensioFrameworkExtraBundle)
Before :
``` yml
@@ -38,3 +38,7 @@ Now :
genemu_base64:
resource: "@GenemuFormBundle/Resources/config/routing/base64.xml"
```
+
+### Captcha
+
+The 'position' option has been removed, if you had it set to 'right', you should add your own template for this type.

0 comments on commit 64b7d33

Please sign in to comment.
Something went wrong with that request. Please try again.