/** * Render form * * @param Zend_View_Interface $view * @return string */ public function render(Zend_View_Interface $view = null) { if ($this->isEnableRenderJqueryValidator()) { $this->_jquery->addJavascriptFile($this->_jqueryValidatePlugin); $this->_jquery->addJavascriptFile($this->_jqueryValidateExtendedPlugin); $js = '' . $this->getJqueryValidatorVar() . ' = $("#' . $this->getId() . '").validate(' . $this->renderJqueryValidatorOptions() . ');'; $this->_jquery->addOnLoad(@$js); } $content = parent::render($view); return $content; }
/** * @group ZF-4859 */ public function testAutocompleteDoesNotDoubleArrayEncodeDataJsonField() { $view = new Zend_View(); $form = new ZendX_JQuery_Form(); $dataSource = array(0 => 'John Doe'); $lastname = new ZendX_JQuery_Form_Element_AutoComplete("Lastname", array('label' => 'Lastname')); $form->addElement($lastname); $form->Lastname->setJQueryParam('source', $dataSource); Zend_Json::$useBuiltinEncoderDecoder = true; $output = $form->render($view); $this->assertEquals(array('$("#Lastname").autocomplete({"source":["John Doe"]});'), $view->jQuery()->getOnLoadActions()); Zend_Json::$useBuiltinEncoderDecoder = false; $output = $form->render($view); $this->assertEquals(array('$("#Lastname").autocomplete({"source":["John Doe"]});'), $view->jQuery()->getOnLoadActions()); }
/** * @group ZF-8055 */ public function testUiWidgetDialogContainerRenderBug() { $view = new Zend_View(); ZendX_JQuery::enableView($view); // Create new jQuery Form $form = new ZendX_JQuery_Form(); $form->setView($view); $form->setAction('formdemo.php'); $form->setAttrib('id', 'mainForm'); // Use a TabContainer for your form: $form->setDecorators(array('FormElements', 'Form', array('DialogContainer', array('id' => 'tabContainer', 'style' => 'width: 600px;', 'jQueryParams' => array('tabPosition' => 'top'))))); $subForm1 = new ZendX_JQuery_Form('subform1'); $subForm1->setView($view); // Add Element Spinner $elem = new ZendX_JQuery_Form_Element_Spinner("spinner1", array('label' => 'Spinner:', 'attribs' => array('class' => 'flora'))); $elem->setJQueryParams(array('min' => 0, 'max' => 1000, 'start' => 100)); $subForm1->addElement($elem); $subForm1->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'dl')))); $form->addSubForm($subForm1, "form1"); $output = $form->render($view); $this->assertContains('<div id="tabContainer" style="width: 600px;"><form', $output); }
/** * * @param Zend_View_Interface $view * @return type */ public function render(Zend_View_Interface $view = null) { $element = new ZendT_Form_Element('clear_both'); $element->setDecorators(array(new ZendT_Form_Decorator_ClearBoth())); $this->addElement($element); if ($this->_enablejQueryValidate) { $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['jQueryFormValidate'] = "jQuery('#" . $this->getId() . "').validate({ignore:[]});"; $this->getView()->placeholder('onLoad')->set($onLoad); } if (count($this->_url) > 1) { $this->getView()->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TForm.js?' . $data); $baseUrl = ZendT_Url::getBaseUrl(); $url = array(); foreach ($this->_url as $key => $value) { $url['url'][$key] = $baseUrl . $value; } $jsonParam = ZendT_JS_Json::encode($url); $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['jQueryForm'] = "jQuery('#" . $this->getId() . "').TForm(" . $jsonParam . ");"; $this->getView()->placeholder('onLoad')->set($onLoad); } if ($this->_enableFocusFirstElement) { $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['jQueryFormFocus'] = "focusFirstElement('#" . $this->getId() . " input, #" . $this->getId() . " textare, #" . $this->getId() . " select');"; $this->getView()->placeholder('onLoad')->set($onLoad); } $enableTinyMCE = false; $elements = $this->getElements(); $tinyMCE = ''; foreach ($elements as $element) { if ($element instanceof ZendT_Form_Element_Textarea) { if ($element->isEditorHtml()) { $tinyMCE .= "tinyMCE.get('" . $element->getId() . "').save();"; $enableTinyMCE = true; } } } if ($enableTinyMCE) { $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['tinyMCE'] = "jQuery('#" . $this->getId() . "').submit(function(){" . $tinyMCE . "});"; $this->getView()->placeholder('onLoad')->set($onLoad); } return parent::render($view); }