public function indexAction() { $form = new ZendX_JQuery_Form(); $date1 = new ZendX_JQuery_Form_Element_DatePicker('date1', array('label' => 'Date:')); $form->addElement($date1); $elem = new ZendX_JQuery_Form_Element_Spinner('spinner1', array('label' => 'Spinner:')); $elem->setJQueryParams(array('min' => 0, 'max' => 1000, 'start' => 100)); $form->addElement($elem); $this->view->form = $form; }
public function addElement($element, $name = null, $options = null, $bAddEmpty = true) { if (!$options) { $options = array(); } if (!isset($options['class'])) { $options['class'] = self::DEFAULT_INPUT_CLS; } if ($element == 'select' and $bAddEmpty) { if (!isset($options['multiOptions'])) { $options['multiOptions'] = array(); } $options['multiOptions'] = array('' => 'wybierz') + $options['multiOptions']; } if (isset($this->_option['readonly'])) { if ($element == 'select') { $options['disabled'] = 'disabled'; } else { if ($element == 'button') { if ($name == 'submit') { $options['class'] = 'hideFormHidden'; } if ($name == 'cancel') { $options['label'] = str_replace($options['label'], "Anuluj", "Powrót"); } } else { $options['class'] = self::DEFAULT_INPUT_CLS; $options['readonly'] = true; } } } return parent::addElement($element, $name, $options); }
/** * @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); }
public function addElement($element, $name = null, $options = null) { if (!$name) { $name = $element->getName(); if (!$name) { throw new Exception('Defina um nome para o campo'); } } parent::addElement($element, $name, $options); $this->decorateElement($this->getElement($name)); return $this; }