public function render(ElementInterface $element) { if ($element->getOption('static')) { return $this->getView()->formElementStatic($element); } return parent::render($element); }
/** * {@inheritDoc} */ public function render(ElementInterface $element) { $captcha = $element->getCaptcha(); if ($captcha === null || !$captcha instanceof CaptchaAdapter) { throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute ' . 'implementing %s; none found', __METHOD__, CaptchaAdapter::class)); } $helper = $captcha->getHelperName(); $renderer = $this->getView(); if (!method_exists($renderer, 'plugin')) { throw new Exception\DomainException(sprintf('%s requires that the renderer implements plugin(); it does not', __METHOD__)); } $helper = $renderer->plugin($helper); if ($helper instanceof TranslatorAwareInterface) { $rollbackTextDomain = $helper->getTranslatorTextDomain(); $helper->setTranslatorTextDomain($this->getTranslatorTextDomain()); } $markup = parent::render($element); if ($helper instanceof TranslatorAwareInterface) { $helper->setTranslatorTextDomain($rollbackTextDomain); } return $markup; }
/** * Captcha element * * @param ElementInterface|null $element * @return string|Helper\FormCaptcha */ public function captcha(ElementInterface $element = null) { $helper = new Helper\FormCaptcha(); return $helper->__invoke($element); }