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; }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $image_name = new Zend_Form_Element_Text('image_name'); $image_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên ảnh không được để trống')); $image_link = new Zend_Form_Element_Textarea('image_link'); $image_link->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Hình ảnh không được để trống')); $is_active = new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('is_active') ->setMultiOptions(array("1" => "Có","0" => "Không")); $image_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $image_link->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($image_name,$image_link,$is_active)); return $form; }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $category_name = new Zend_Form_Element_Text('category_name'); $category_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên danh mục không được để trống')); /* $category_parent_id = new Zend_Form_Element_Select('category_parent_id'); $category_parent_id->addMultiOption('', '0'); foreach($this->mDanhmuc->getListDM() as $item) { $category_parent_id->addMultiOption($item['category_name'], $item['category_id']); } */ $is_active = $form->createElement("select","is_active",array( "label" => "Kích hoạt", "multioptions"=> array( "0" => "Chưa kích hoạt", "1" => "Đã kích hoạt"))); $category_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($category_name,$is_active)); return $form; }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $user_login = new Zend_Form_Element_Text('user_login'); $user_login->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên đăng nhập không được để trống')); $user_pass = new Zend_Form_Element_Password('user_pass'); $user_pass->setAttrib('renderPassword', true); $user_pass->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mật khẩu không được để trống')); $user_fullname = new Zend_Form_Element_Text('user_fullname'); $user_fullname->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên người dùng không được để trống')); $user_email = new Zend_Form_Element_Text('user_email'); $user_email->addValidator('EmailAddress',true,array('messages'=>'Địa chỉ email không hợp lệ')); $user_email->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Email không được để trống')); $user_address = new Zend_Form_Element_Text('user_address'); $user_address->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Địa chỉ không được để trống')); $user_login->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_pass->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_fullname->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_email->removeDecorator('HtmlTag')->removeDecorator('Label'); $user_address->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($user_login,$user_pass,$user_fullname,$user_email,$user_address)); return $form; }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $youtube_username = new Zend_Form_Element_Text('youtube_username'); $youtube_username->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên tài khoản không được để trống')); $password = new Zend_Form_Element_Text('password'); $password->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mật khẩu không được để trống')); $youtube_gallery = new Zend_Form_Element_Text('youtube_gallery'); $youtube_gallery->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên album không được để trống')); $is_selected = $form->createElement("select","is_selected",array( "label" => "Kích hoạt", "multioptions"=> array( "0" => "Không", "1" => "Có"))); $youtube_username->removeDecorator('HtmlTag')->removeDecorator('Label'); $password->removeDecorator('HtmlTag')->removeDecorator('Label'); $youtube_gallery->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_selected->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($youtube_username,$password,$youtube_gallery,$is_selected)); return $form; }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $ads_banner = new Zend_Form_Element_Textarea('ads_banner'); $ads_banner->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Biểu ngữ không được để trống')); $ads_position = new Zend_Form_Element_Text('ads_position'); $ads_position->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Vị trí không được để trống')); $ads_name = new Zend_Form_Element_Text('ads_name'); $ads_name->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tên quảng cáo không được để trống')); $ads_link = new Zend_Form_Element_Text('ads_link'); $ads_link->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Đường dẫn không được để trống')); $ads_position = $form->createElement("select","ads_position",array( "label" => "Vị trí", "multioptions"=> array( "1" => "Trên", "2" => "Giữa", "3" => "Trái", "4" => "Phải", "5" => "Nội dung"))); $ads_banner->removeDecorator('HtmlTag')->removeDecorator('Label'); $ads_position->removeDecorator('HtmlTag')->removeDecorator('Label'); $ads_name->removeDecorator('HtmlTag')->removeDecorator('Label'); $ads_link->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($ads_banner,$ads_position,$ads_name,$ads_link)); return $form; }
public function removeAction() { $form = new Zend_Form(); $form->setView(new Zend_View()); $form->setMethod('post'); $form->setAction(''); $form->setAttrib('class', 'devel'); $form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name')); $handleOptions = explode(',', $this->getRequest()->getParam('handles')); $referenceOptions = explode(',', $this->getRequest()->getParam('references')); $handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used')); $handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper'))); $referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper'))); $handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper'))); $handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used'))); $reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions))); $name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true)); $submit = $form->createElement('submit', 'submit', array('label' => 'Submit')); $form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit)); if ($form->isValid($this->getRequest()->getParams())) { $localXmlWriter = Mage::getModel('devel/writer_localxml'); $localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue()); $localXmlWriter->save(); die('DONE. You need to reload to see changes!'); } else { $this->loadLayout(); $this->getLayout()->getUpdate()->load('devel_layout_wizard'); $this->getLayout()->generateXml(); $this->loadLayout(); $this->getLayout()->getBlock('devel_wizard_form')->setForm($form); $this->renderLayout(); } }
/** * Hook for node form - if type is Guestbook Node, add extra fields * * @param Zend_Form $form * @param array $arguments */ public function nodeForm(Zend_Form &$form, &$arguments) { $item =& array_shift($arguments); if ($item->type == "guestbook_entry") { // Add guestbook fields $name = new Zend_Form_Element_Text('guestbook_name', array('size' => 35)); $name->setLabel('Name'); $name->setRequired(true); $email = new Zend_Form_Element_Text('guestbook_email', array('size' => 35)); $email->setLabel('Email'); $email->setRequired(true)->addValidator(new Zend_Validate_StringLength(6))->addValidator(new Zend_Validate_EmailAddress()); $url = new Zend_Form_Element_Text('guestbook_homepage', array('size' => 35)); $url->setLabel('Homepage'); $url->setRequired(false)->addValidator(new Zend_Validate_StringLength(4))->addValidator(new Zend_Validate_Hostname()); $form->addElements(array($name, $email, $url)); $options = array('legend' => Zoo::_("Guest information")); $form->addDisplayGroup(array('guestbook_name', 'guestbook_email', 'guestbook_homepage'), 'guestbook_add', $options); if ($item->id > 0) { // Fetch guestbook object $factory = new Guestbook_Node_Factory(); $guestbook = $factory->find($item->id)->current(); if (!$guestbook) { $guestbook = $factory->createRow(); } $values = $guestbook->toArray(); $populate = array(); foreach ($values as $key => $value) { $populate['guestbook_' . $key] = $value; } $form->populate($populate); } } }
public function setupDisplayGroups() { $this->testCanAddAndRetrieveMultipleElements(); $this->form->addElements(array('test1' => 'text', 'test2' => 'text', 'test3' => 'text', 'test4' => 'text')); $this->form->addDisplayGroup(array('bar', 'bat'), 'barbat'); $this->form->addDisplayGroup(array('foo', 'baz'), 'foobaz'); }
function setForm() { $form = new Zend_Form; $form->setMethod('post')->setAction(''); //$this->setAttrib('enctype','multipart/form-data'); $file = new Zend_Form_Element_File('video_file'); //$file->setAttrib('class','file'); $file->setLabel('video_file'); $file->setRequired(true); $video_title = new Zend_Form_Element_Text('video_title'); $video_title ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Tiêu đề không được để trống')); $video_thumbnail=new Zend_Form_Element_Textarea('video_thumbnail'); $video_thumbnail->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_description = new Zend_Form_Element_Textarea('video_description'); $video_description->setAttrib('rows','7'); $video_description ->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Mô tả không được để trống')); $is_active = new Zend_Form_Element_Radio('is_active'); $is_active->setRequired(true) ->setLabel('is_active') ->setMultiOptions(array("1" => "Có","0" => "Không")); $file->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_title->removeDecorator('HtmlTag')->removeDecorator('Label'); $video_description->removeDecorator('HtmlTag')->removeDecorator('Label'); $is_active->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($file,$video_title,$video_description,$is_active,$video_thumbnail)); return $form; }
/** * Create create_agreement form. * * @param string $community_id * @return Zend_Form */ public function createCreateAgreementForm($community_id) { $form = new Zend_Form(); $form->setAction($this->webroot . '/communityagreement/community/agreementtab?communityId=' . $community_id)->setMethod('post'); $agreement = new Zend_Form_Element_Textarea('agreement'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->t('Save')); $form->addElements(array($agreement, $submit)); return $form; }
public function getForm() { $elementDecorators = array(array('Label'), array('ViewHelper'), array('Errors')); $form = new Zend_Form(); $form->setAction("/teacher/dashboard/view-student/stid/{$this->_stid}/")->setMethod('post'); $mailSubject = new Zend_Form_Element_Text('subject', array('id' => 'mailsubj', 'label' => 'Subject')); $mailBody = new Zend_Form_Element_Textarea('mailbody', array('id' => 'mailbody', 'label' => 'Message', 'cols' => 40, 'rows' => 5)); $mailSend = new Zend_Form_Element_Submit('mailsend', array('id' => 'mailsend', 'label' => 'send')); $form->addElements(array($mailSubject, $mailBody, $mailSend)); return $form; }
public function getForm() { $elementDecorators = array(array('Label'), array('ViewHelper'), array('Errors')); $form = new Zend_Form(); $form->setAction('/student/profile/my-profile/')->setMethod('post'); $mailSubject = new Zend_Form_Element_Text('subject', array('id' => 'mailsubj', 'label' => 'Subject', 'maxLength' => '30')); $mailBody = new Zend_Form_Element_Textarea('mailbody', array('id' => 'mailbody', 'label' => 'Message', 'cols' => 40, 'rows' => 5)); $mailSend = new Zend_Form_Element_Submit('mailsend', array('id' => 'mailsend', 'label' => 'send')); $form->addElements(array($mailSubject, $mailBody, $mailSend)); return $form; }
/** create form */ public function createKeyForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/apikey/usertab')->setMethod('post'); $appplication_name = new Zend_Form_Element_Text('appplication_name'); $expiration = new Zend_Form_Element_Text('expiration'); $submit = new Zend_Form_Element_Submit('createAPIKey'); $submit->setLabel($this->t('Generate New API Key')); $form->addElements(array($appplication_name, $expiration, $submit)); return $form; }
/** create edit bitstream form */ public function createEditBitstreamForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/item/editbitstream')->setMethod('post'); $name = new Zend_Form_Element_Text('name'); $name->setRequired(true)->addValidator('NotEmpty', true); $mimetype = new Zend_Form_Element_Text('mimetype'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->t('Save')); $form->addElements(array($name, $mimetype, $submit)); return $form; }
/** create upload link form */ public function createUploadLinkForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/upload/savelink')->setMethod('post'); $validator = new Zend_Validate_Callback(array('Zend_Uri', 'check')); $name = new Zend_Form_Element_Text('name'); $name->setRequired(true); $url = new Zend_Form_Element_Text('url'); $url->setValue('http://')->setRequired(true)->addValidator($validator)->addValidator('NotEmpty', true); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->t('Save Link'))->setAttrib('class', 'globalButton'); $form->addElements(array($name, $url, $submit)); return $form; }
public function indexAction() { $this->view->title = 'admin_title_statistic'; $years = $this->_statisticsModel->getYears(); $highest = max($years); $selectYear = new Zend_Form_Element_Select('selectedYear', array("multiOptions" => $years, "value" => $highest)); $selectYear->setRequired(true)->setLabel($this->view->translate('Select_Year_Label')); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->view->translate('Submit_Button_Label')); $form = new Zend_Form(); $form->setAction($this->view->url(array("controller" => "statistic", "action" => "show"))); $form->addElements(array($selectYear, $submit)); $this->view->form = $form; }
/** create edit folder form */ public function createEditForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/folder/edit')->setMethod('post'); $name = new Zend_Form_Element_Text('name'); $name->setAttribs(array('placeholder' => $this->t('Name of the folder'), 'autofocus' => 'autofocus', 'required' => 'required'))->setRequired(true)->addValidator('NotEmpty', true); $description = new Zend_Form_Element_Textarea('description'); $description->setAttribs(array('placeholder' => $this->t('Optional'))); $teaser = new Zend_Form_Element_Text('teaser'); $teaser->setAttribs(array('placeholder' => $this->t('Optional'))); $teaser->setAttrib('MAXLENGTH', '250'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel($this->t('Save')); $form->addElements(array($name, $description, $submit, $teaser)); return $form; }
/** create form */ public function createConfigForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/install/step3')->setMethod('post'); $lang = new Zend_Form_Element_Select('lang'); $lang->addMultiOptions(array('en' => 'English', 'fr' => 'French')); $timezone = new Zend_Form_Element_Select('timezone'); $timezone->addMultiOptions(array('America/Anchorage' => 'America/Anchorage', 'America/Chicago' => 'America/Chicago', 'America/Denver' => 'America/Denver', 'America/Los_Angeles' => 'America/Los Angeles', 'America/New_York' => 'America/New York', 'America/Phoenix' => 'America/Phoenix', 'Europe/London' => 'Europe/London', 'Europe/Paris' => 'Europe/Paris', 'Pacific/Honolulu' => 'Pacific/Honolulu', 'UTC' => 'UTC')); $description = new Zend_Form_Element_Textarea('description'); $name = new Zend_Form_Element_Text('name'); $name->setRequired(true)->addValidator('NotEmpty', true); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Create configuration'); $form->addElements(array($description, $timezone, $lang, $name, $submit)); return $form; }
/** * @group ZF-10491 * @group ZF-10734 * @group ZF-10731 */ public function testAddElementToDisplayGroupByElementInstance() { $element = new Zend_Form_Element_Text('foo'); $elementTwo = new Zend_Form_Element_Text('baz-----'); $this->form->addElements(array($element, $elementTwo)); $this->form->addDisplayGroup(array($element, $elementTwo), 'bar'); $displayGroup = $this->form->getDisplayGroup('bar'); $this->assertNotNull($displayGroup->getElement('foo')); $this->assertNotNull($displayGroup->getElement('baz')); // clear display groups and elements $this->form->clearDisplayGroups()->clearElements(); $this->form->addDisplayGroup(array($element, $elementTwo), 'bar'); $displayGroup = $this->form->getDisplayGroup('bar'); $this->assertNotNull($displayGroup->getElement('foo')); $this->assertNotNull($displayGroup->getElement('baz')); }
/** * The default action - show the home page */ public function indexAction() { // Create form $form = new Zend_Form(); $form->setEnctype('multipart/form-data'); // File element... $fileEle = new Zend_Form_Element_File("projectImage", array('label' => 'Image File:')); $fileEle->setMultiFile(3); // Add elements + submit button $form->addElements(array($fileEle, new Zend_Form_Element_Submit('projectSubmitImageUpload', array('label' => 'Upload Image')))); // Show the form echo $form; // Check if we have a form post, and if it's valid if ($this->getRequest()->isPost() && $form->isValid($_POST)) { // you'll never get here! } }
private function _getLoginForm() { $form = new Zend_Form(); $form->setMethod('POST'); $form->setName('userLoginForm'); $username = new Zend_Form_Element_Text('username'); $username->setLabel('User name')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Alnum')->addValidator('StringLength', false, array(3, 24)); $password = new Zend_Form_Element_Password('password'); $password->setLabel('Password')->setRequired(true)->setValue(null)->addValidator('StringLength', false, array(6)); $realm = new Zend_Form_Element_Select('realm'); $realm->setLabel('Role')->addMultiOptions(array('user' => 'User', 'admin' => 'Admin'))->setRequired(true)->setValue('user'); $rememberMe = new Zend_Form_Element_Checkbox('rememberMe'); $rememberMe->setLabel('Remember Me'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Login'); $form->addElements(array($realm, $username, $password, $rememberMe, $submit)); return $form; }
/** * Hook for node form - if type is Estate Node, add extra fields * * @param Zend_Form $form * @param array $arguments */ public function nodeForm(Zend_Form &$form, &$arguments) { $item =& array_shift($arguments); $title = new Zend_Form_Element_Text('title', array('class' => 'content_title')); $title->setLabel('Title'); $title->setRequired(true)->addValidator(new Zend_Validate_StringLength(2, 255)); $content = new Zoo_Form_Element_Wysiwyg('content'); $content->setRequired(false)->setLabel('Content')->setAttrib('cols', 50); $form->addElements(array($title, $content)); $form->addDisplayGroup(array('title', 'content'), 'content_add', array('legend' => Zoo::_('Content'))); if (Zend_Auth::getInstance()->hasIdentity()) { $identity = Zend_Auth::getInstance()->getIdentity(); $uid = $identity->id; } else { $uid = 0; } $filters = Zoo::getService('filter')->getFiltersByUser($uid); if ($filters && $filters->count() > 0) { foreach ($filters as $filter) { $options = array(); if (!$filter->optional) { $options = array('disabled' => 'disabled', 'value' => 1); } elseif ($item->id == 0) { $options['value'] = $filter->default; } $ele = new Zend_Form_Element_Checkbox("filter_" . $filter->name, $options); $ele->setLabel($filter->name); $form->addElement($ele); $elements[] = "filter_" . $filter->name; $userfilters[$filter->id] = $filter; } $options = array('legend' => Zoo::_("Filters")); $form->addDisplayGroup($elements, 'filter_set', $options); if ($item->id > 0) { // Fetch set filters $filters = Zoo::getService('content')->getFilters($item); $populate = array(); foreach ($filters as $filter) { $populate['filter_' . $userfilters[$filter->filter_id]->name] = 1; } $form->populate($populate); } } }
/** * 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"); }
function setForm() { $form=new Zend_Form; $form->setMethod('post')->setAction(''); $danhmuc = new Zend_Form_Element_Text('danhmuc'); $noidung = new Zend_Form_Element_Text('noidung'); $noidung->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Nội dung không được để trống')); $lienket = new Zend_Form_Element_Text('lienket'); $lienket->setRequired(true)->addValidator('NotEmpty',true,array('messages'=>'Liên kết không được để trống')); $danhmuc->removeDecorator('HtmlTag')->removeDecorator('Label'); $noidung->removeDecorator('HtmlTag')->removeDecorator('Label'); $lienket->removeDecorator('HtmlTag')->removeDecorator('Label'); $form->addElements(array($danhmuc,$noidung,$lienket)); return $form; }
/** * Hook for node form - if type is Estate Node, add extra fields * * @param Zend_Form $form * @param array $arguments */ public function nodeForm(Zend_Form &$form, &$arguments) { $item =& array_shift($arguments); if ($item->type == "estate_node") { // Add estate fields $price = new Zend_Form_Element_Text('estate_price', array('size' => 10)); $price->setLabel('Price'); $price->setRequired(true)->addValidator(new Zend_Validate_Int()); $area = new Zend_Form_Element_Text('estate_area', array('size' => 5)); $area->setLabel('Area'); $area->setRequired(true)->addValidator(new Zend_Validate_StringLength(1, 5))->addValidator(new Zend_Validate_Int()); $rooms = new Zend_Form_Element_Text('estate_rooms', array('size' => 5)); $rooms->setLabel('Rooms'); $rooms->setRequired(true)->addValidator(new Zend_Validate_StringLength(1, 5))->addValidator(new Zend_Validate_Int()); $floors = new Zend_Form_Element_Select('estate_floors'); $floors->setLabel('Floors'); $floors->addMultiOptions(array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '>5')); $year = new Zend_Form_Element_Text('estate_year'); $year->setLabel('Built Year'); $year->setRequired(true)->addValidator(new Zend_Validate_GreaterThan(1500))->addValidator(new Zend_Validate_Int()); $ground = new Zend_Form_Element_Text('estate_ground'); $ground->setLabel('Ground area'); $ground->setRequired(true)->addValidator(new Zend_Validate_Int()); $form->addElements(array($price, $area, $rooms, $floors, $year, $ground)); $options = array('legend' => Zoo::_("Real estate information")); $form->addDisplayGroup(array('estate_price', 'estate_area', 'estate_rooms', 'estate_floors', 'estate_year', 'estate_ground'), 'estate_add', $options); if ($item->id > 0) { // Fetch estate object $factory = new Estate_Node_Factory(); $estate = $factory->find($item->id)->current(); if (!$estate) { $estate = $factory->createRow(); } $values = $estate->toArray(); $populate = array(); foreach ($values as $key => $value) { $populate['estate_' . $key] = $value; } $form->populate($populate); } } }
/** * Initiate system installation * */ public function indexAction() { $settingsform = new Zoo_Form_Settings(); $modulesform = new Zoo_Form_Modules(); $form = new Zend_Form(array('name' => 'installForm')); $form->setSubFormDecorators(array('FormElements', 'Fieldset')); $form->addSubForm($settingsform, 'settings'); $form->addSubForm($modulesform, 'modules'); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($settingsform->isValid($formData)) { // $this->_forward('install'); } $form->populate($formData); } $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Install'); $form->addElements(array($submit)); $this->view->form = $form; }
/** * Get registration form for a new user * * @return Zend_Form */ function getRegistrationForm() { $form = new Zend_Form(); $form->setAction("/register")->setMethod('post'); $username = new Zend_Form_Element_Text('username'); $username->setLabel('Username'); $username->setRequired(true)->addValidator(new Zend_Validate_StringLength(2, 255)); $password = new Zend_Form_Element_Password('password'); $password->setRequired(true)->setLabel('Password'); $submit = new Zend_Form_Element_Submit('save'); $submit->setLabel('Register'); $form->addElements(array($username, $password)); $form->addDisplayGroup(array('username', 'password'), 'user_register', array('legend' => Zoo::_('Register user'))); try { Zoo::getService("hook")->trigger("User", "Registerform", $form); } catch (Zoo_Exception_Service $e) { // Hook service not available - log? Better not, some people may live happily without a hook service } $form->addElement($submit); return $form; }
/** create form */ public function createConfigForm() { $form = new Zend_Form(); $form->setAction($this->webroot . '/admin/index')->setMethod('post'); $lang = new Zend_Form_Element_Select('lang'); $lang->addMultiOptions(array('en' => 'English', 'fr' => 'French')); $description = new Zend_Form_Element_Textarea('description'); $timezone = new Zend_Form_Element_Select('timezone'); $timezone->addMultiOptions(array('America/Anchorage' => 'America/Anchorage', 'America/Chicago' => 'America/Chicago', 'America/Denver' => 'America/Denver', 'America/Los_Angeles' => 'America/Los Angeles', 'America/New_York' => 'America/New York', 'America/Phoenix' => 'America/Phoenix', 'Europe/London' => 'Europe/London', 'Europe/Paris' => 'Europe/Paris', 'Pacific/Honolulu' => 'Pacific/Honolulu', 'UTC' => 'UTC')); $name = new Zend_Form_Element_Text('name'); $name->setRequired(true)->addValidator('NotEmpty', true); $dynamichelp = new Zend_Form_Element_Checkbox('dynamichelp'); $gravatar = new Zend_Form_Element_Checkbox('gravatar'); $allowPasswordReset = new Zend_Form_Element_Checkbox('allow_password_reset'); $closeRegistration = new Zend_Form_Element_Checkbox('closeregistration'); $httpProxy = new Zend_Form_Element_Text('httpProxy'); $submit = new Zend_Form_Element_Submit('submitConfig'); $submit->setLabel('Save configuration'); $form->addElements(array($dynamichelp, $description, $timezone, $gravatar, $lang, $name, $allowPasswordReset, $closeRegistration, $submit, $httpProxy)); return $form; }
public function getForm() { $elementDecorators = array(array('Label'), array('ViewHelper'), array('Errors')); $form = new Zend_Form(); $form->setAction('/student/profile/feedback/')->setMethod('post'); $improvement = new Zend_Form_Element_Radio('improvement', array('label' => '', 'separator' => '', 'multiOptions' => array('Yes' => 'Yes', 'No' => 'No'))); $improvement->setDecorators($elementDecorators); $level = new Zend_Form_Element_Radio('level', array('label' => '', 'separator' => '', 'multiOptions' => array('Hard' => 'Hard', 'Suitable' => 'Suitable', 'Easy' => 'Easy'))); $level->setAttrib('class', 'radio_new'); $level->setDecorators($elementDecorators); $difficult = new Zend_Form_Element_Text('difficult', array('id' => 'difficult', 'maxLength' => '50')); $difficult->setDecorators($elementDecorators); $difficult->setAttrib('class', 'sub_text_input'); $suggestions = new Zend_Form_Element_Textarea('suggestions', array('label' => '?האם חווית בעיה בתרגול', 'id' => 'suggestions')); $suggestions->setAttrib('class', 'sub_textarea'); $sendFeedback = new Zend_Form_Element_Button('sendfeedback', array('id' => 'sendfeedback', 'label' => 'ds')); $sendFeedback->setAttrib('class', 'sub_button_input'); $sendFeedback->setDecorators($elementDecorators); $form->addElements(array($improvement, $level, $difficult, $suggestions)); return $form; }