/** * @param UploaderModelInterface $model * @param null $values * @return string * @throws InvalidArgumentException */ public function render($model, $values = null) { if (!$model instanceof UploaderModelInterface) { throw new InvalidArgumentException("Unsupportable type of model, required type UploaderModelInterface"); } $textArea = new Textarea(); $textArea->setName('response'); $textAreaViewHelper = new FormTextarea(); $jsonEncoder = new Json(); $value = $jsonEncoder->encode($model->getVariables()); $textArea->setValue($value); return $textAreaViewHelper->render($textArea); }
public function render(ElementInterface $element) { if ($element->getOption('static')) { return $this->getView()->formElementStatic($element); } return parent::render($element); }
/** * Textarea * * @param ElementInterface|null $element * @return string|Helper\FormTextarea */ public function textarea(ElementInterface $element = null) { $helper = new Helper\FormTextarea(); return $helper->__invoke($element); }
/** * Render a form <input> text element from the provided $element, * @param ElementInterface $element * @param null|string $formType * @param array $displayOptions * @return string */ public function render(ElementInterface $element, $formType = null, array $displayOptions = array()) { $this->prepareElementBeforeRendering($element, $formType, $displayOptions); $html = parent::render($element); return $html; }
/** * @see \Zend\Form\View\Helper\FormTextarea::render() * @param \Zend\Form\ElementInterface $element * @return string */ public function render(\Zend\Form\ElementInterface $oElement) { $this->getCustomPlaceHolder()->__invoke('bottomScripts')->append('<script language="JavaScript">CKEDITOR.replace(' . \Zend\Json\Json::encode($oElement->getName()) . ');</script>'); return parent::render($oElement); //.$this->getEscapeJsHelper()->__invoke('CKEDITOR.replace('.\Zend\Json\Json::encode($oElement->getName()).')'); }
/** * @see \Zend\Form\View\Helper\FormTextarea::render() * @param \Zend\Form\ElementInterface $element * @return string */ public function render(\Zend\Form\ElementInterface $oElement) { return parent::render($oElement) . $this->getEscapeJsHelper()->__invoke(' CKEDITOR.replace(' . \Zend\Json\Json::encode($oElement->getName()) . '); '); }
/** * @return string */ public function render(\Zend\Form\ElementInterface $oElement) { $config = $this->getConfig(); $name = $oElement->getName(); // Check whether some options have been passed via the form element // options $options = $oElement->getOption('ckeditor'); if (!empty($options) && !is_array($options)) { throw \Exception('The options should either be an array or a traversable object'); } elseif (empty($options)) { $options = array(); } $ckfinderLoaded = $this->getModuleManager()->getModule('CKFinderModule') !== null; // Because zf merges arrays instead of overwriting them in the config, // we allow a callback and use the return as the toolbar array if (array_key_exists('toolbar', $config['ckeditor_options']) && is_callable($config['ckeditor_options']['toolbar'])) { $toolbar = $config['ckeditor_options']['toolbar'](); if (is_array($toolbar)) { $config['ckeditor_options']['toolbar'] = $toolbar; } } // Merge the defaut edito options with the form element options // and turn them into json $jsonOptions = JsonFormatter::encode(array_merge($config['ckeditor_options'], $ckfinderLoaded ? $config['ckeditor_ckfinder_options'] : array(), $options), true); $loadFunctionName = $this->getTmpLoadFunctionName(); $src = $config['src']; return parent::render($oElement) . '<script type="text/javascript" language="javascript">' . "\n" . 'if(typeof window.ckEditorLoading == "undefined"){' . "\n" . 'window.ckEditorLoading = false;' . "\n" . 'window.ckEditorCallbacks = [];' . "\n" . '}' . "\n" . '(function() {' . "\n" . 'function ' . $loadFunctionName . '(){' . "\n" . 'CKEDITOR.replace("' . $name . '", ' . $jsonOptions . ');' . "\n" . '}' . "\n" . 'if(typeof CKEDITOR == "undefined"){' . "\n" . 'window.ckEditorCallbacks.push(' . $loadFunctionName . ');' . "\n" . 'if(!window.ckEditorLoading) {' . "\n" . 'window.ckEditorLoading = true;' . "\n" . 'var ckScript = document.createElement("script");' . "\n" . 'ckScript.type = "text/javascript";' . "\n" . 'ckScript.async = false;' . "\n" . 'ckScript.src = "' . $src . '";' . "\n" . 'var target = document.getElementsByTagName("script")[0];' . "\n" . 'target.parentNode.insertBefore(ckScript, target);' . "\n" . 'var ckEditorInterval = setInterval(function(){' . "\n" . 'if(typeof CKEDITOR != "undefined"){' . "\n" . 'clearInterval(ckEditorInterval);' . "\n" . 'for(var i in window.ckEditorCallbacks) window.ckEditorCallbacks[i]();' . "\n" . '}' . "\n" . '}, 100);' . "\n" . '}' . "\n" . '}' . "\n" . '})();' . "\n" . '</script>' . "\n"; }