[CaptchaType] Makes sure that the field is empty on form loading (fixes

This commit is contained in:
Gregwar 2011-12-14 10:28:21 +01:00
parent bfd012ffe0
commit 53e5605103
1 changed files with 5 additions and 1 deletions

View File

@ -13,6 +13,7 @@ use Symfony\Component\Form\Exception\FormException;
use Gregwar\CaptchaBundle\Validator\CaptchaValidator;
use Gregwar\CaptchaBundle\Generator\CaptchaGenerator;
use Gregwar\CaptchaBundle\DataTransformer\EmptyTransformer;
/**
* Captcha type
@ -121,6 +122,7 @@ class CaptchaType extends AbstractType
public function buildForm(FormBuilder $builder, array $options)
{
$this->key = $builder->getForm()->getName();
$builder->addValidator(
new CaptchaValidator($this->session, $this->key)
);
@ -147,6 +149,8 @@ class CaptchaType extends AbstractType
if ($this->keepValue) {
$this->session->set($this->key.'_fingerprint', $generator->getFingerprint());
}
$view->set('value', '');
}
public function getDefaultOptions(array $options = array())