public function init() { $this->_selectOptions = array('1' => 'red', '2' => 'blue', '3' => 'gray'); $this->setMethod('post'); $this->setAttribs(array('name' => 'masterform')); $this->setDecorators(array('FormElements', array('TabContainer', array('id' => 'tabContainer', 'style' => 'width:660px; height:500px', 'dijitParams' => array('tabPosition' => 'top')), 'DijitForm'))); $textForm = new Zend_Dojo_Form_SubForm(); $textForm->setAttribs(array('name' => 'textboxtab', 'legend' => 'Text Elements', 'dijitParams' => array('title' => 'Text Elements'))); $textForm->addElement('TextBox', 'textbox', array('value' => 'some text', 'label' => 'TextBox', 'trim' => true, 'propercase' => true)); $textForm->addElement('DateTextBox', 'datebox', array('value' => '2008-07-05', 'label' => 'DateTexBox', 'required' => true)); $textForm->addElement('TimeTextBox', 'timebox', array('label' => 'TimeTexBox', 'required' => true)); $textForm->addElement('CurrencyTextBox', 'currencybox', array('label' => 'CurrencyTexBox', 'required' => true, 'currency' => 'USD', 'invalidMessage' => 'Invalid amount', 'symbol' => 'USD', 'type' => 'currency')); $textForm->addElement('NumberTextBox', 'numberbox', array('label' => 'NumberTexBox', 'required' => true, 'invalidMessage' => 'Invalid elevation.', 'constraints' => array('min' => -2000, 'max' => 2000, 'places' => 0))); $textForm->addElement('ValidationTextBox', 'validationbox', array('label' => 'ValidationTexBox', 'required' => true, 'regExp' => '[\\w]+', 'invalidMessage' => 'invalid non-space text.')); $textForm->addElement('Textarea', 'textarea', array('label' => 'TextArea', 'required' => true, 'style' => 'width:200px')); $toggleForm = new Zend_Dojo_Form_SubForm(); $toggleForm->setAttribs(array('name' => 'toggletab', 'legend' => 'Toggle Elements')); $toggleForm->addElement('NumberSpinner', 'ns', array('value' => '7', 'label' => 'NumberSpinner', 'smallDelta' => 5, 'largeDelta' => 25, 'defaultTimeout' => 1000, 'timeoutChangeRate' => 100, 'min' => 9, 'max' => 1550, 'places' => 0, 'maxlength' => 20)); $toggleForm->addElement('Button', 'dijitButton', array('label' => 'Button')); $toggleForm->addElement('CheckBox', 'checkbox', array('label' => 'CheckBox', 'checkedValue' => 'foo', 'uncheckedValue' => 'bar', 'checked' => true)); $selectForm = new Zend_Dojo_Form_SubForm(); $selectForm->setAttribs(array('name' => 'selecttab', 'legend' => 'Select Elements')); $selectForm->addElement('ComboBox', 'comboboxselect', array('label' => 'ComboBox(select)', 'value' => 'blue', 'autocomplete' => false, 'multiOptions' => $this->_selectOptions)); $selectForm->addElement('FilteringSelect', 'filterselect', array('label' => 'FilteringSelect(select)', 'value' => 'blue', 'autocomplete' => false, 'multiOptions' => $this->_selectOptions)); $this->addSubForm($textForm, 'textForm')->addSubForm($toggleForm, 'toggleForm')->addSubForm($selectForm, 'selectForm'); }
public function init() { $this->setDecorators(array('FormElements', array('TabContainer', array('id' => 'tabContainer', 'style' => 'width: 640px; height: 500px;', 'dijitParams' => array('tabPosition' => 'top'))), 'DijitForm')); // Set the method for the display form to POST $this->setMethod('post'); $basicForm = new Zend_Dojo_Form_SubForm(); $basicForm->setAttribs(array('name' => 'toggletab', 'legend' => 'Basics')); // Add an email element $basicForm->addElement('TextBox', 'code', array('label' => 'Product Code:', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 32))))); // Add an email element $basicForm->addElement('DateTextBox', 'created', array('label' => 'Created On:', 'required' => false, 'filters' => array('StringTrim'))); // Add an email element $basicForm->addElement('TextBox', 'name', array('label' => 'Product Name:', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 80))))); // Add the comment element $basicForm->addElement('Textarea', 'description', array('label' => 'Description:', 'required' => true, 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 200))))); // Add an email element $basicForm->addElement('CurrencyTextBox', 'listPrice', array('label' => 'Product List Price:', 'required' => true, 'currency' => 'USD', 'symbol' => 'USD', 'type' => 'currency', 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'Float')))); $xtraForm = new Zend_Dojo_Form_SubForm(); $xtraForm->setAttribs(array('name' => 'toggle2', 'legend' => 'Extra')); // Add an email element $xtraForm->addElement('TextBox', 'nada', array('label' => 'Foo Bar!:', 'required' => false, 'filters' => array('StringTrim'))); // Add the submit button $basicForm->addElement('SubmitButton', 'submit', array('ignore' => true, 'label' => 'Save Product')); $this->addSubForm($basicForm, 'textboxtab'); $this->addSubForm($xtraForm, 'textboxtab2'); // And finally add some CSRF protection $this->addElement('hash', 'csrf', array('ignore' => true)); /* $this->setElementDecorators(array( 'DijitElement', 'Errors', array(array('data'=>'HtmlTag'),array('tag'=>'td')), array('Label',array('tag'=>'td')), array(array('row'=>'HtmlTag'),array('tag'=>'tr')) )); $this->setDecorators(array( 'FormElements', array(array('data'=>'HtmlTag'), array('tag'=>'table','cellspacing'=>'4')), 'DijitForm' )); * */ }
public function testShouldUseLegendAttribAsTitleIfNoTitlePresent() { $element = new Zend_Dojo_Form_SubForm(); $element->setAttribs(array('name' => 'foo', 'legend' => 'FooBar', 'style' => 'width: 300px; height: 500px;', 'class' => 'someclass'))->setView($this->view); $this->decorator->setElement($element); $html = $this->decorator->render(''); $this->assertContains('FooBar', $html); }
/** * @group ZF-4435 */ public function testShouldCreateAppropriateIdsForElementsInSubForms() { $form = new Zend_Dojo_Form(); $form->setDecorators(array('FormElements', array('TabContainer', array('id' => 'tabContainer', 'style' => 'width: 600px; height: 300px;', 'dijitParams' => array('tabPosition' => 'top'))), 'DijitForm')); $sliderForm = new Zend_Dojo_Form_SubForm(); $sliderForm->setAttribs(array('name' => 'slidertab', 'legend' => 'Slider Elements')); $sliderForm->addElement('HorizontalSlider', 'slide1', array('label' => 'Slide me:', 'minimum' => 0, 'maximum' => 25, 'discreteValues' => 10, 'style' => 'width: 450px;', 'topDecorationDijit' => 'HorizontalRuleLabels', 'topDecorationLabels' => array('0%', '50%', '100%'), 'topDecorationParams' => array('style' => 'padding-bottom: 20px;'))); $form->addSubForm($sliderForm, 'slidertab')->setView($this->getView()); $html = $form->render(); $this->assertContains('id="slidertab-slide1-slider"', $html); $this->assertContains('id="slidertab-slide1-slider-topDecoration"', $html); $this->assertContains('id="slidertab-slide1-slider-topDecoration-labels"', $html); }