From 1437f0c7e027373f366c75b69ad80b08315b5e8e Mon Sep 17 00:00:00 2001 From: Jeremy Livingston Date: Mon, 3 Dec 2012 18:54:39 -0500 Subject: [PATCH] Remove caching of form name for key --- Type/CaptchaType.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Type/CaptchaType.php b/Type/CaptchaType.php index ba2463b..9c91951 100644 --- a/Type/CaptchaType.php +++ b/Type/CaptchaType.php @@ -36,12 +36,6 @@ class CaptchaType extends AbstractType */ private $options = array(); - /** - * Session key - * @var string - */ - private $key = 'captcha'; - /** * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session * @param \Gregwar\CaptchaBundle\Generator\CaptchaGenerator $generator @@ -60,9 +54,13 @@ class CaptchaType extends AbstractType */ public function buildForm(FormBuilderInterface $builder, array $options) { - $this->key = $builder->getForm()->getName(); + $validator = new CaptchaValidator( + $this->session, + $builder->getForm()->getName(), + $options['invalid_message'], + $options['bypass_code'] + ); - $validator = new CaptchaValidator($this->session, $this->key, $options['invalid_message'], $options['bypass_code']); $builder->addEventListener(FormEvents::POST_BIND, array($validator, 'validate')); } @@ -76,7 +74,7 @@ class CaptchaType extends AbstractType $view->vars = array_merge($view->vars, array( 'captcha_width' => $options['width'], 'captcha_height' => $options['height'], - 'captcha_code' => $this->generator->getCaptchaCode($this->key, $options), + 'captcha_code' => $this->generator->getCaptchaCode($form->getName(), $options), 'value' => '', )); }