/** * Setup decorators and properties common for all elements */ protected function setupElementsCommon() { $viewElementDecorator = new My_Decorator_ViewElement(); $viewElementDecorator->setLanguagePack($this->lang); $this->form->clearDecorators(); $this->form->setElementDecorators(array($viewElementDecorator)); }
public function getForm() { $form = new Zend_Form(); $form->setMethod('post'); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report5Form.phtml')))); $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC'); $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px')); $form->addElement($e); $items = $this->getGuideItems('T_REPORTPLANKIND'); $e = new Zend_Form_Element_Select('reportplankind', array('label' => 'Звіт/план', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 200px')); $form->addElement($e); $items = $this->getGuideItems('T_EDUFORM', false); $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); $items = $this->getGuideItems('T_EDUBASIS', false); $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); $items = $this->getGuideItems('T_COUNTRYTYPE', true); $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); if (@(!$this->params['establishment'])) { $e = new Zend_Form_Element_Checkbox('indpapers', array('label' => 'Індивідуальні аркуші')); $form->addElement($e); } $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show')); $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'")); $form->addElement($e); $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 5)); $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'")); $form->addElement($e); $form->setElementDecorators(array('ViewHelper', 'Errors')); return $form; }
public function testShouldAllowSpecifyingListOfElementsNotToDecorate() { $this->setupElements(); $this->form->setElementDecorators( array( 'Description', 'FormDecorator', 'Fieldset', ), array( 'foo', 'baz', ), false ); $element = $this->form->bar; $this->assertFalse($element->getDecorator('ViewHelper')); $this->assertFalse($element->getDecorator('Errors')); $this->assertFalse($element->getDecorator('Label')); $this->assertFalse($element->getDecorator('HtmlTag')); $decorator = $element->getDecorator('Description'); $this->assertTrue($decorator instanceof \Zend\Form\Decorator\Description); $decorator = $element->getDecorator('FormDecorator'); $this->assertTrue($decorator instanceof \Zend\Form\Decorator\FormDecorator); $decorator = $element->getDecorator('Fieldset'); $this->assertTrue($decorator instanceof \Zend\Form\Decorator\Fieldset); foreach (array('foo', 'baz') as $name) { $element = $this->form->$name; $this->assertFalse($element->getDecorator('FormDecorator')); $this->assertFalse($element->getDecorator('Fieldset')); } }
public function getForm() { $form = new Zend_Form(); $form->setMethod('post'); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report4Form.phtml')))); $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_PLAN_YEAR'); $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px')); $form->addElement($e); $items = $this->getGuideItems('T_EDUFORM', false); $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); $items = $this->getGuideItems('T_EDUBASIS', false); $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); $items = $this->getGuideItems('T_COUNTRYTYPE', false); $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show')); $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'")); $form->addElement($e); $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 4)); $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'")); $form->addElement($e); $form->setElementDecorators(array('ViewHelper', 'Errors')); return $form; }
public static function getMailForm($docid) { $form = new Zend_Form(); $form->setMethod('post')->setAttrib('onsubmit', 'return checkReply(this);')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'zend_form')), 'Form')); $form->addElements(array(array('select', 'to', array('label' => 'To', 'required' => true, 'multiOptions' => array_merge(array('' => ''), array_keys(self::getRecipients($docid))))), array('text', 'replyto', array('label' => 'Your e-mail address', 'validators' => array(array('EmailAddress')))), array('textarea', 'body', array('label' => 'Message body', 'required' => true, 'rows' => '7', 'cols' => '70', 'validators' => array(array('StringLength', true, array(0, 5000))), 'filters' => array('StringTrim'))))); $form->setElementDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')))); $form->addElements(array(array('captcha', 'captcha', array('label' => 'Enter safety code', 'required' => true, 'ignore' => true, 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 600), 'decorators' => array('Captcha', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td'))))), array('submit', 'submit', array('label' => 'Send', 'decorators' => array('ViewHelper', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array(array('Label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))))))); return $form; }
/** * Set Form defaults * - disable default decorators * - set form & displaygroup decorators * - set needed prefix path for bootstrap decorators * - set form element decorators * * @param Zend_Form $form The form instance. * @param string $format Standard, minimal, table. * * @return void */ protected static function setFormDefaults(Zend_Form $form, $format) { $form->setDisableLoadDefaultDecorators(true); $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]); $form->setDecorators(self::$_FormDecorator[$format]); if (self::BOOTSTRAP == $format || self::BOOTSTRAP_MINIMAL == $format) { $form->addElementPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR); $form->addPrefixPath('Dfi_Form_Decorator', 'Dfi/Form/Decorator', Zend_Form::DECORATOR); } $form->setElementDecorators(self::$_ElementDecorator[$format]); return; }
public function getForm() { $form = new Zend_Form(); $form->setMethod(Zend_Form::METHOD_POST); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'requests/reqForm.phtml')))); $items = $this->getGuideYears(); $e = new Zend_Form_Element_Select('year', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'value' => reset($items))); $form->addElement($e); $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити')); $form->addElement($e); $form->setElementDecorators(array('ViewHelper', 'Errors')); return $form; }
public function getInfoForm() { $form = new Zend_Form(); $form->setAction('')->setMethod(Zend_Form::METHOD_POST)->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'import/infoForm10.phtml'), 'Form'))); $e = new Zend_Form_Element_Hidden('step', array('value' => 2)); $form->addElement($e); $e = new Zend_Form_Element_Hidden('filename'); $form->addElement($e); $e = new Zend_Form_Element_Hidden('validreports'); $form->addElement($e); $e = new Zend_Form_Element_Submit('submit', array('label' => 'Далі')); $form->addElement($e); $form->setElementDecorators(array('ViewHelper')); return $form; }
public function getForm() { $form = new Zend_Form(); $form->setMethod('post'); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report9Form.phtml')))); $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT_YEAR_SPEC'); $e = new Zend_Form_Element_Select('period', array('label' => 'Рік', 'multiOptions' => $items, 'required' => true, 'style' => 'width: 80px')); $form->addElement($e); $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show')); $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'")); $form->addElement($e); $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 9)); $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'")); $form->addElement($e); $form->setElementDecorators(array('ViewHelper', 'Errors')); return $form; }
/** * The main workshop page. It has the list of all the workshops that are * available in the system. * */ public function indexAction() { $this->view->acl = array('workshopList' => $this->_helper->hasAccess('workshop-list')); $get = Zend_Registry::get('getFilter'); $form = new Zend_Form(); $form->setAttrib('id', 'workshopForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form')); $searchField = $form->createElement('text', 'search', array('label' => 'workshop-index-index:searchWorkshops')); $searchField->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($get->search) ? $get->search : ''); $category = new Category(); $categoryList = $category->fetchAll(null, 'name'); $categories = $form->createElement('select', 'categoryId'); $categories->addMultiOption('', '-- Search By Category -- '); foreach ($categoryList as $c) { $categories->addMultiOption($c['categoryId'], $c['name']); } $categories->setValue(isset($get->categoryId) ? $get->categoryId : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'workshop-index-index:search')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($searchField, $categories)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); $this->view->form = $form; $searchTerm = new Search_Term(); $workshops = array(); if ($get->search != '' || $get->categoryId != 0) { $workshop = new Workshop(); $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); if ($get->search != '') { $query->addTerm(new Zend_Search_Lucene_Index_Term($get->search), true); } if ($get->categoryId != 0) { $query->addTerm(new Zend_Search_Lucene_Index_Term($get->categoryId, 'categoryId'), true); } $workshops = $workshop->search($query); $searchTerm->increment($get->search); $this->view->searchTerm = $get->search; } $this->view->workshops = $workshops; $this->view->topTerms = $searchTerm->getTopSearchTerms(10); $this->view->layout()->setLayout('search'); $this->view->layout()->rightContent = $this->view->render('index/top-terms.phtml'); $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js'); $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css'); $this->_helper->pageTitle("workshop-index-index:title"); }
public function getForm() { $form = new Zend_Form(); $form->setMethod('post'); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report8Form.phtml')))); $items = $this->getPeriodItems('REQ_EDUSTAT_FAIL'); $e = new Zend_Form_Element_Select('period', array('label' => 'На дату', 'multiOptions' => $items, 'required' => true)); $form->addElement($e); $items = $this->getGuideItems('T_DEPARTMENT', true); $e = new Zend_Form_Element_Select('department', array('label' => 'Факультет', 'multiOptions' => $items, 'style' => 'width: 200px')); $form->addElement($e); $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show')); $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'")); $form->addElement($e); $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 8)); $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'")); $form->addElement($e); $form->setElementDecorators(array('ViewHelper', 'Errors')); return $form; }
public function getForm() { $form = new Zend_Form(); $form->setMethod('post'); $form->setDecorators(array(array('ViewScript', array('viewScript' => 'reports/report1Form.phtml')))); $items = $this->getPeriodItems('REQ_MOZ_CONTMOVEMENT'); $e = new Zend_Form_Element_Select('period', array('label' => 'Період', 'multiOptions' => $items, 'required' => true)); $form->addElement($e); $items = $this->getGuideItems('T_STRUCTURE_ITEM', true, false, 'CT.TITLE'); $e = new Zend_Form_Element_Select('establishment', array('label' => 'Установа', 'multiOptions' => $items)); $form->addElement($e); $items = $this->getGuideItems('T_EDUFORM', true); $e = new Zend_Form_Element_Select('eduform', array('label' => 'Форма навчання', 'multiOptions' => $items)); $form->addElement($e); $items = $this->getGuideItems('T_EDUBASIS', true); $e = new Zend_Form_Element_Select('edubase', array('label' => 'Форма фінансування', 'multiOptions' => $items)); $form->addElement($e); $items = $this->getGuideItems('T_COUNTRY', true); $e = new Zend_Form_Element_Select('country', array('label' => 'Громадянство (країна)', 'multiOptions' => $items)); $form->addElement($e); $items = $this->getGuideItems('T_COUNTRYTYPE', true); $e = new Zend_Form_Element_Select('countrytype', array('label' => 'Тип громадянства', 'multiOptions' => $items)); $form->addElement($e); $items = $this->getGuideItems('T_EDULEVEL'); $e = new Zend_Form_Element_MultiCheckbox('edulevel', array('label' => 'Рівень підготовки', 'multiOptions' => $items)); $e->setValue(array_keys($items)); $form->addElement($e); $refreshAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'page', 'action' => 'show')); $e = new Zend_Form_Element_Submit('refresh', array('label' => 'Обновити', 'onclick' => "document.forms[0].action='{$refreshAct}'")); $form->addElement($e); $excelAct = Zend_Controller_Action_HelperBroker::getStaticHelper('url')->url(array('controller' => 'reports', 'action' => 'excel', 'report' => 1)); $e = new Zend_Form_Element_Submit('excel', array('label' => 'Excel', 'onclick' => "document.forms[0].action='{$excelAct}'")); $form->addElement($e); $form->setElementDecorators(array('ViewHelper', 'Errors')); $auth = Zend_Auth::getInstance(); $ident = $auth->getIdentity(); if ($ident->STRUCTURE_CODE != 0) { $form->getElement('establishment')->setValue($ident->STRUCTUREID); } return $form; }
/** * Gets the form for adding and editing a location * * @param array $values * @return Zend_Form */ public function form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'locationTypeForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $name = $form->createElement('text', 'name', array('label' => 'Name:')); $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : ''); // $status = $form->createElement('select', 'status', array('label' => 'Status:')); // $status->addMultiOption('enabled', 'Enabled'); // $status->addMultiOption('disabled', 'Disabled'); // $status->setValue((isset($values['status']) ? $values['status'] : 'enabled')); // $capacity = $form->createElement('text', 'capacity', array('label' => 'Capacity:')); // $capacity->setRequired(true) // ->addFilter('StringTrim') // ->addFilter('StripTags') // ->addValidator('Digits') // ->setAttrib('maxlength', '64') // ->setValue((isset($values['capacity']) ? $values['capacity'] : '')); // $address = $form->createElement('text', 'address', array('label' => 'Address:')); // $address->setRequired(true) // ->addFilter('StringTrim') // ->addFilter('StripTags') // ->setAttrib('maxlength', '255') // ->setValue((isset($values['address']) ? $values['address'] : '')); $description = $form->createElement('textarea', 'description', array('label' => 'Description:')); $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->addElements(array($name, $description)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); if (isset($values['typeId'])) { $locationId = $form->createElement('hidden', 'typeId'); $locationId->setValue($values['typeId']); $locationId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($locationId); } return $form; }
public function form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'categoryForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $name = $form->createElement('text', 'name', array('label' => 'Name:')); $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '64')->setValue(isset($values['name']) ? $values['name'] : ''); $description = $form->createElement('textarea', 'description', array('label' => 'Description:')); $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 300px;')->setValue(isset($values['description']) ? $values['description'] : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->addElements(array($name, $description)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); if (isset($values['categoryId'])) { $categoryId = $form->createElement('hidden', 'categoryId'); $categoryId->setValue($values['categoryId']); $categoryId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($categoryId); } return $form; }
/** * Gets the form for adding and editing a location * * @param array $values * @return Zend_Form */ public function form($values = array()) { require_once APPLICATION_PATH . '/models/Workshop/Category.php'; $form = new Zend_Form(); $form->setAttrib('id', 'workshopForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $title = $form->createElement('text', 'title', array('label' => 'Workshop Title:')); $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['title']) ? $values['title'] : ''); $group = $form->createElement('select', 'group', array('label' => 'Offered By:')); $group->addMultiOption('groupId1', 'Test Group1'); $group->addMultiOption('groupId2', 'Test Group2'); $group->setValue(isset($values['group']) ? $values['group'] : null); //TODO: change this to add all the enabled groups in the database $tags = $form->createElement('text', 'tags', array('label' => 'Tags:')); $tags->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['tags']) ? implode(', ', $values['tags']) : ''); $status = $form->createElement('select', 'status', array('label' => 'Status:')); $status->addMultiOption('enabled', 'Enabled'); $status->addMultiOption('disabled', 'Disabled'); $status->setValue(isset($values['status']) ? $values['status'] : 'enabled'); $category = new Category(); $categoryList = $category->fetchAll(null, 'name'); $categories = $form->createElement('select', 'categoryId', array('label' => 'Worshop Category: ')); $categories->setRequired(true); foreach ($categoryList as $category) { $categories->addMultiOption($category->categoryId, $category->name); } $categories->setValue(isset($values['categoryId']) ? $values['categoryId'] : ''); $prerequisites = $form->createElement('textarea', 'prerequisites', array('label' => 'workshop-index-add:preRequisites')); $prerequisites->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['prerequisites']) ? $values['prerequisites'] : ''); $featured = $form->createElement('checkbox', 'features', array('label' => 'Featured?')); $featured->setValue(isset($values['featured']) ? $values['featured'] : null); $description = $form->createElement('textarea', 'description', array('label' => 'Description:')); $description->setRequired(false)->addFilter('StringTrim')->setAttrib('style', 'width: 95%; height: 200px;')->setValue(isset($values['description']) ? $values['description'] : ''); $editors = $form->createElement('multiselect', 'editors', array('label' => 'Workshop Editors:')); $editors->setRequired(false)->setAttrib('size', '10'); $account = new Ot_Account(); $accounts = $account->fetchAll(null, array('lastName', 'firstName')); foreach ($accounts as $a) { $editors->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')'); } $editors->setValue(isset($values['editors']) ? $values['editors'] : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->addElements(array($status, $title, $categories, $group, $tags, $description, $prerequisites, $editors)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); if (isset($values['workshopId'])) { $workshopId = $form->createElement('hidden', 'workshopId'); $workshopId->setValue($values['workshopId']); $workshopId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($workshopId); } return $form; }
$file->setLabel('File')->setRequired(true)->setValueDisabled(False)->addValidator('Extension', FALSE, 'jpg,jpeg')->addValidator('Size', false, array('min' => 20, 'max' => 20000000)); $file->getValidator('Extension')->setMessage('JPEGs only'); // Create text area for message $message = new Zend_Form_Element_Textarea('message'); $message->setRequired(TRUE)->setAttrib('id', 'message')->addErrorMessage('Please specify a message'); // Create a submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Submit')->setAttrib('id', 'submit'); // Set the ViewScript decorator for the form and tell it which // template file to use $form->setDecorators(array(array('ViewScript', array('viewScript' => 'form-contact.tpl.php')))); // Add the form elements AFTER the viewscript decorator has been set $form->addElements(array($file, $message, $submit)); // Get rid of all element decorators except for ViewHelper to render // the individual elements and Errors decorator to render the errors. $form->setElementDecorators(array('ViewHelper', 'Errors')); // The file element requires the File decorator instead of the // ViewHelper decorator $file->setDecorators(array('File', 'Errors')); // Create an instance of Zend_View and set the directory // for the template files $view = new Zend_View(); $view->setScriptPath(__DIR__); // Tell all the elements in the form which view to use when rendering foreach ($form as $item) { $item->setView($view); } // process or display the form if (isset($_POST['submit']) && $form->isValid($_POST)) { $uploadHandler = new Zend_File_Transfer_Adapter_Http(); $uploadHandler->setDestination(__DIR__ . '/uploads/');
/** * Get the form used for confirming deletions. * * @see deleteConfirmAction() * @see deleteAction() * @return Zend_Form */ protected function _getDeleteForm() { $form = new Zend_Form(); $form->setElementDecorators(array('ViewHelper')); $form->removeDecorator('HtmlTag'); $form->addElement('hash', 'confirm_delete_hash'); $form->addElement('submit', 'Delete', array('class' => 'delete red button')); $form->setAction($this->view->url(array('action' => 'delete'))); return $form; }
public function rollForm($values = array()) { if (!isset($values['eventId'])) { throw new Ot_Exception_Data('Event ID must be provided'); } $form = new Zend_Form(); $form->setAttrib('id', 'rollForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $attendee = new Event_Attendee(); $attendees = $attendee->getAttendeesForEvent($values['eventId'], 'attending'); $otAccount = new Ot_Account(); $attendeeList = array(); foreach ($attendees as $a) { $thisAccount = $otAccount->find($a['accountId']); if (!is_null($thisAccount)) { $attendeeList[$a['accountId']] = $thisAccount->firstName . ' ' . $thisAccount->lastName . ' (' . $thisAccount->username . ')'; } } $attendeeElement = $form->createElement('multiCheckbox', 'attendees'); $attendeeElement->setMultiOptions($attendeeList)->setValue(isset($values['attendees']) ? $values['attendees'] : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->addElements(array($attendeeElement)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); $eventId = $form->createElement('hidden', 'eventId'); $eventId->setValue($values['eventId']); $eventId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($eventId); return $form; }
public function form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'reportingForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $fromDate = $form->createElement('text', 'fromDate', array('label' => 'reporting-index-index:fromDate')); $fromDate->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['fromDate']) ? $values['fromDate'] : ''); $toDate = $form->createElement('text', 'toDate', array('label' => 'reporting-index-index:toDate')); $toDate->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($values['toDate']) ? $values['toDate'] : strftime('%B %e, %Y', time())); $submit = $form->createElement('submit', 'submitButton', array('label' => 'reporting-index-index:getReport')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($fromDate, $toDate)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); return $form; }
public function addAttendeeForm($values = array()) { if (!isset($values['eventId'])) { throw new Ot_Exception_Input('The event ID must be provided.'); } $form = new Zend_Form(); $form->setAttrib('id', 'locationForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $eventId = $form->createElement('hidden', 'eventId'); $eventId->setValue($values['eventId']); $eventId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($eventId); $type = $form->createElement('select', 'type', array('label' => 'How to Add:')); $type->addMultiOption('firstAvailable', 'First Available Spot')->addMultiOption('attending', 'Add To Attending List')->setValue(isset($values['type']) ? $values['type'] : ''); // get all the users available for the instructor list $otAccount = new Ot_Account(); $accounts = $otAccount->fetchAll(null, array('lastName', 'firstName'))->toArray(); $userList = array(); foreach ($accounts as $a) { $userList[$a['accountId']] = $a['lastName'] . ", " . $a['firstName']; } // remove anyone who's either in the attendee list, waitlist, or an instructor // for this event so they can't be added to the list $attendee = new Event_Attendee(); $attendeeList = $attendee->getAttendeesForEvent($values['eventId'], 'attending'); $waitlist = $attendee->getAttendeesForEvent($values['eventId'], 'waitlist'); $instructors = $this->getInstructorsForEvent($values['eventId']); foreach ($attendeeList as $a) { unset($userList[$a['accountId']]); } foreach ($waitlist as $w) { unset($userList[$w['accountId']]); } foreach ($instructors as $i) { unset($userList[$i['accountId']]); } $users = $form->createElement('multiselect', 'users', array('label' => 'User Search:')); $users->setMultiOptions($userList)->setAttrib('size', 10)->setValue(isset($values['accountIds']) ? $values['accountIds'] : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->addElements(array($type, $users)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); return $form; }
public function addInterfaceCheckbox($value) { $form = new Zend_Form(); $checkbox_element = new Zend_Form_Element_Checkbox("checktoogleInterface"); $checkbox_element->setValue($value); $checkbox_element->setAttrib("id", "checktoogleInterface"); $form->addElement($checkbox_element); $form->setElementDecorators(array('ViewHelper')); $form->setDecorators(array('FormElements', 'Form')); $this->view->interfacingcheckbox = $form; }
/** * @group ZF-12387 */ public function testAddElementAsObjectGetsElementDecoratorsIfNoneIsExplicitlySet() { // Init form $form = new Zend_Form(); $form->setElementDecorators(array(new Zend_Form_Decorator_ViewHelper(), new Zend_Form_Decorator_Label())); // Add element $element = new Zend_Form_Element_Text('foo', array('disableLoadDefaultDecorators' => true)); $form->addElement($element); // Test $expected = array('Zend_Form_Decorator_ViewHelper', 'Zend_Form_Decorator_Label'); $actual = array(); foreach ($form->getElement('foo')->getDecorators() as $decorator) { $actual[] = get_class($decorator); } $this->assertEquals($expected, $actual); }
protected static function setElementsDecoratorDefaults(Zend_Form $form, $format) { $form->setElementDecorators(self::$_ElementDecorator[$format]); return; }
/** * Gets the form for adding and editing a document * * @param array $values * @return Zend_Form */ public function form($values = array()) { $config = Zend_Registry::get('config'); $form = new Zend_Form(); $form->setAttrib('id', 'documentForm')->setAttrib('enctype', 'multipart/form-data')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $file = $form->createElement('file', 'document', array('label' => 'Upload File:')); $file->setRequired(true)->addValidator('Count', false, 1)->addValidator('Size', false, 10240000)->addValidator('Extension', false, $config->user->fileUploadAllowableExtensions->val ? $config->user->fileUploadAllowableExtensions->val : ""); if (!isset($values['workshopDocumentId'])) { $form->addElement($file); } $title = $form->createElement('text', 'description', array('label' => 'File Description:')); $title->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['description']) ? $values['description'] : ''); $form->addElement($title); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); $file->setDecorators(array('File', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span')))); if (isset($values['workshopDocumentId'])) { $workshopDocumentId = $form->createElement('hidden', 'workshopDocumentId'); $workshopDocumentId->setValue($values['workshopDocumentId']); $workshopDocumentId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($workshopDocumentId); } return $form; }
public function form() { $form = new Zend_Form(); $form->setAttrib('id', 'workshopForm')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'eval_form')), 'Form')); $ca = new Ot_Custom(); $custom = $ca->getAttributesForObject('evaluations', 'Zend_Form'); foreach ($custom as $c) { $form->addElement($c['formRender']); } $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit Evaluation')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); return $form; }
/** * Setup decorators and properties common for all elements */ protected function setupElementsCommon() { $this->form->setElementDecorators(array('ViewHelper', array('Description', array('placement' => 'append', 'tag' => 'span', 'class' => 'description')))); }
public function getForm() { $form = new Zend_Form(); $form->setName($this->poClass . "_form"); $schema = $this->schema->getSchema(); foreach ($this->getEditableProperties() as $propertyName => $property) { $methodName = 'get' . ucfirst($propertyName) . 'Element'; if (method_exists($this, $methodName)) { $form->addElement($this->{$methodName}()); continue; } $dbField = $schema[$this->poDef->table]->fields[$property->columnName]; $dbType = $dbField->type; switch ($dbType) { case 'integer': case 'timestamp': case 'boolean': $element = new Zend_Form_Element_Text($propertyName); $element->addValidator('allnum'); $element->addFilter('int'); break; case 'float': case 'decimal': $element = new Zend_Form_Element_Text($propertyName); break; case 'blob': case 'clob': $element = new Zend_Form_Element_Textarea($propertyName); break; case 'text': case 'time': case 'date': default: $element = new Zend_Form_Element_Text($propertyName); break; } if (list($relatedClassName, $relationDef) = $this->isFK($property->columnName)) { $element = new Zend_Form_Element_Select($propertyName); $pos = ezcPersistentSessionInstance::get(); $q = $pos->createFindQuery($relatedClassName); $this->queryHook($q); $list = $pos->find($q, $relatedClassName); $element->options = $list; $element->addFilter('int'); } if (!$this->isNullProperty($property->columnName, $this->poDef->table)) { $element->setRequired(true)->addValidator('NotEmpty'); } $element->setLabel($propertyName); $form->addElement($element); } $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Submit'); $form->addElement($submit); $form->clearDecorators(); $form->addDecorator('FormElements')->addDecorator('HtmlTag', array('tag' => '<ul>'))->addDecorator('Form'); $form->setElementDecorators(array(array('ViewHelper'), array('Errors'), array('Description'), array('Label', array('separator' => ' ')), array('HtmlTag', array('tag' => 'li', 'class' => 'element-group')))); // buttons do not need labels $submit->setDecorators(array(array('ViewHelper'), array('Description'), array('HtmlTag', array('tag' => 'li', 'class' => 'submit-group')))); $form->setView(new Zend_View()); return $form; }
/** * Gets the form for adding and editing a document * * @param array $values * @return Zend_Form */ public function form($values = array()) { $form = new Zend_Form(); $form->setAttrib('id', 'documentForm')->setAttrib('enctype', 'multipart/form-data')->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')), 'Form')); $name = $form->createElement('text', 'name', array('label' => 'Link Name:')); $name->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '255')->setValue(isset($values['name']) ? $values['name'] : ''); $url = $form->createElement('text', 'url', array('label' => 'URL:')); $url->setRequired(true)->addFilter('StringTrim')->addFilter('StripTags')->setAttrib('maxlength', '5000')->setValue(isset($values['url']) ? $values['url'] : ''); $form->addElements(array($name, $url)); $submit = $form->createElement('submit', 'submitButton', array('label' => 'Submit')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $cancel = $form->createElement('button', 'cancel', array('label' => 'Cancel')); $cancel->setAttrib('id', 'cancel'); $cancel->setDecorators(array(array('ViewHelper', array('helper' => 'formButton')))); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit, $cancel)); if (isset($values['workshopLinkId'])) { $workshopLinkId = $form->createElement('hidden', 'workshopLinkId'); $workshopLinkId->setValue($values['workshopLinkId']); $workshopLinkId->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden')))); $form->addElement($workshopLinkId); } return $form; }
public function historyAction() { $account = new Ot_Account(); $thisAccount = Zend_Auth::getInstance()->getIdentity(); $get = Zend_Registry::get('getFilter'); if (isset($get->accountId)) { if ($this->_helper->hasAccess('edit-all-reservations', 'workshop_signup')) { $thisAccount = $account->find($get->accountId); } if (is_null($thisAccount)) { throw new Ot_Exception_Data('msg-error-accountNotFound'); } } if (is_null($thisAccount)) { throw new Ot_Exception_Data('msg-error-notLoggedIn'); } $this->view->acl = array('editAllReservations' => $this->_helper->hasAccess('edit-all-reservations', 'workshop_signup')); $form = new Zend_Form(); $form->setAttrib('id', 'accountForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form')); $accountSelect = $form->createElement('select', 'accountId', array('label' => 'default-index-history:viewReservations')); $accountSelect->setRequired(false); $account = new Ot_Account(); $accounts = $account->fetchAll(null, array('lastName', 'firstName')); foreach ($accounts as $a) { $accountSelect->addMultiOption($a->accountId, $a->firstName . ' ' . $a->lastName . ' (' . $a->username . ')'); } $submit = $form->createElement('submit', 'submitButton', array('label' => 'default-index-history:lookup')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($accountSelect)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); $this->view->form = $form; $event = new Event(); $myEvents = $event->getEventsForUser($thisAccount->accountId); $this->view->myEvents = $myEvents['currentEvents']; $this->view->myPastEvents = $myEvents['pastEvents']; $this->view->account = $thisAccount->toArray(); $this->view->hideFeature = true; $this->_helper->layout->setLayout('my'); $this->view->messages = $this->_helper->flashMessenger->getMessages(); $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js'); $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css'); }
/** * Set the form decorators by the given string format or by the default div style * * @param object $objForm Zend_Form pointer-reference * @param string $constFormat Project_Plugin_FormDecoratorDefinition constants * @return NULL */ public static function setFormDecorator(Zend_Form $form, $format = self::BOOTSTRAP, $submit_str = 'submit', $cancel_str = 'cancel') { /** * - disable default decorators * - set form & displaygroup decorators */ $form->setDisableLoadDefaultDecorators(true); $form->setDisplayGroupDecorators(self::$_DisplayGroupDecorator[$format]); $form->setDecorators(self::$_FormDecorator[$format]); // set needed prefix path for bootstrap decorators if ($format == self::BOOTSTRAP) { $form->addElementPrefixPath('EasyBib_Form_Decorator', 'EasyBib/Form/Decorator', Zend_Form::DECORATOR); } // set form element decorators $form->setElementDecorators(self::$_ElementDecorator[$format]); // set submit button decorators if ($form->getElement($submit_str)) { $form->getElement($submit_str)->setDecorators(self::$_SubmitDecorator[$format]); if ($format == self::BOOTSTRAP) { $attribs = $form->getElement($submit_str)->getAttrib('class'); if (empty($attribs)) { $attribs = array('btn', 'primary'); } else { if (is_string($attribs)) { $attribs = array($attribs); } $attribs = array_unique(array_merge(array('btn'), $attribs)); } $form->getElement($submit_str)->setAttrib('class', $attribs)->setAttrib('type', 'submit'); if ($form->getElement($cancel_str)) { $form->getElement($submit_str)->getDecorator('HtmlTag')->setOption('openOnly', true); } } } // set cancel button decorators if ($form->getElement($cancel_str)) { $form->getElement($cancel_str)->setDecorators(self::$_ResetDecorator[$format]); if ($format == self::BOOTSTRAP) { $attribs = $form->getElement($cancel_str)->getAttrib('class'); if (empty($attribs)) { $attribs = array('btn'); } else { if (is_string($attribs)) { $attribs = array($attribs); } $attribs = array_unique(array_merge(array('btn'), $attribs)); } $form->getElement($cancel_str)->setAttrib('class', $attribs)->setAttrib('type', 'reset'); if ($form->getElement($submit_str)) { $form->getElement($cancel_str)->getDecorator('HtmlTag')->setOption('closeOnly', true); } } } // set hidden input decorators foreach ($form->getElements() as $e) { if ($e->getType() == 'Zend_Form_Element_Hidden') { $e->setDecorators(self::$_HiddenDecorator[$format]); } } }