public function testSubmitElement() { /** @var Fieldset $buttons */ $buttons = $this->testedObject->get('buttons'); $buttonInput = $buttons->get('button'); $this->assertInstanceOf('Zend\\Form\\Element\\Submit', $buttonInput); }
public function indexAction() { /** @var \Zend\Http\Request $request */ $request = $this->getRequest(); try { if ($request->isPost()) { $this->form->setData($request->getPost()->toArray() ?: array()); if ($this->form->isValid()) { $mailer = $this->getPluginManager()->get('Mailer'); $url = $this->plugin('url'); // we cannot check reCaptcha twice (security protection) so we have to remove it $filter = $this->form->getInputFilter()->remove('captcha'); $this->service->proceed($filter, $mailer, $url); $this->notification()->success('An Email with an activation link has been sent, please try to check your email box'); } else { $this->notification()->danger('Please fill form correctly'); } } } catch (Exception\UserAlreadyExistsException $e) { $this->notification()->danger('User with this email address already exists'); } catch (\Exception $e) { $this->logger->crit($e); $this->notification()->danger('An unexpected error has occurred, please contact your system administrator'); } $this->form->setAttribute('action', $this->url()->fromRoute('lang/register')); return array('form' => $this->form); }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * * @return Register */ public function createService(ServiceLocatorInterface $serviceLocator) { /** * @var $filter RegisterInputFilter */ $filter = $serviceLocator->get('Auth\\Form\\RegisterInputFilter'); $config = $serviceLocator->get('Config'); $captchaConfig = isset($config['captcha']) ? $config['captcha'] : array(); $form = new Register(null, array('captcha' => $captchaConfig)); $form->setInputfilter($filter); return $form; }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * * @return Register */ public function createService(ServiceLocatorInterface $serviceLocator) { /** * @var $serviceLocator \Zend\Form\FormElementManager * @var $filter RegisterInputFilter */ $filter = $serviceLocator->getServiceLocator()->get('Auth\\Form\\RegisterInputFilter'); /* @var $config CaptchaOptions */ $config = $serviceLocator->getServiceLocator()->get('Auth/CaptchaOptions'); $form = new Register(null, $config); $form->setAttribute('id', 'registration'); $form->setInputfilter($filter); return $form; }
public function testRoleValue() { $options = new CaptchaOptions(); $testedObject = new Register(null, $options, 'user'); $roleField = $testedObject->get('register')->get('role'); $this->assertTrue($roleField->getValue() == 'user'); }
public function indexAction() { if (!$this->options->getEnableRegistration()) { $this->notification()->info('Registration is disabled'); return $this->redirect()->toRoute('lang'); } /** @var \Zend\Http\Request $request */ $request = $this->getRequest(); $viewModel = new ViewModel(); try { if ($request->isPost()) { $this->form->setData($request->getPost()->toArray() ?: array()); if ($this->form->isValid()) { $mailer = $this->getPluginManager()->get('Mailer'); $url = $this->plugin('url'); // we cannot check reCaptcha twice (security protection) so we have to remove it $filter = $this->form->getInputFilter()->remove('captcha'); $this->service->proceed($filter, $mailer, $url); $this->notification()->success('An Email with an activation link has been sent, please try to check your email box'); $viewModel->setTemplate('auth/register/completed'); } else { $viewModel->setTemplate(null); $this->notification()->danger('Please fill form correctly'); } } else { /* @var $register \Zend\Form\Fieldset */ $register = $this->form->get('register'); $register->get('role')->setValue($this->params('role')); } } catch (Exception\UserAlreadyExistsException $e) { $this->notification()->danger('User with this email address already exists'); } catch (\Auth\Exception\UserDeactivatedException $e) { $this->notification()->danger('User with this email address already exists'); } catch (\Exception $e) { $this->logger->crit($e); $this->notification()->danger('An unexpected error has occurred, please contact your system administrator'); } $this->form->setAttribute('action', $this->url()->fromRoute('lang/register')); $viewModel->setVariable('form', $this->form); return $viewModel; }