当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form类代码示例

本文整理汇总了PHP中Zend_Form的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form类的具体用法?PHP Zend_Form怎么用?PHP Zend_Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: nodeForm

 /**
  * Hook for node form - if type is Filemanager Node, add extra fields
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeForm(Zend_Form &$form, &$arguments)
 {
     $item =& array_shift($arguments);
     if (!Zend_Controller_Front::getInstance()->getRequest()->isXmlHttpRequest() && $item->type == "filemanager_file") {
         // Add Filemanager fields
         $form->setAttrib('enctype', 'multipart/form-data');
         $file = new Zend_Form_Element_File('filemanager_file');
         $file->setLabel("Select file")->setDestination(ZfApplication::$_data_path . DIRECTORY_SEPARATOR . "files")->setRequired(false);
         $form->addElement($file);
         $fields[] = 'filemanager_file';
         if ($item->id > 0) {
             // Fetch Filemanager object
             $factory = new Filemanager_File_Factory();
             $file_item = $factory->find($item->id)->current();
             if ($file_item) {
                 $existing = new Zend_Form_Element_Image('filemanager_image');
                 if (substr($file_item->mimetype, 0, 5) == "image") {
                     $imageid = $file_item->nid;
                 } else {
                     $imageid = 0;
                 }
                 $urlOptions = array('module' => 'filemanager', 'controller' => 'file', 'action' => 'show', 'id' => $imageid);
                 $existing->setImage(Zend_Controller_Front::getInstance()->getRouter()->assemble($urlOptions, 'default'));
                 $fields[] = 'filemanager_image';
             }
         }
         $options = array('legend' => Zoo::_("File upload"));
         $form->addDisplayGroup($fields, 'filemanager_fileupload', $options);
     } else {
         // Add content node image selector
     }
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:38,代码来源:Node.php

示例2: testEmptyFormNameShouldNotRenderEmptyFormId

 public function testEmptyFormNameShouldNotRenderEmptyFormId()
 {
     $form = new Zend_Form();
     $form->setMethod('post')->setAction('/foo/bar')->setView($this->getView());
     $html = $form->render();
     $this->assertNotContains('id=""', $html, $html);
 }
开发者ID:lortnus,项目名称:zf1,代码行数:7,代码来源:FormTest.php

示例3: setForm

		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;
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:27,代码来源:DanhmucController.php

示例4: setForm

		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;
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:25,代码来源:ImageController.php

示例5: addElementJobFunctionId

 /**
  * Adds an element JobFunctionId.<br/><br/>
  * Defaults:<br/>
  * name         = job_function_id<br/>
  * requires     = true<br/>
  * label        = Business unit<br/>
  * placeholder  = 'Choose a job function'<br/>
  * dimension    = 6<br/>
  * modelfield   = job_function_id<br/>
  * firstvaluenull  = true
  * 
  * @param Zend_Form $form The Zend_Form object where the element will be added
  * @param array $options The options to pass in the element
  */
 public function addElementJobFunctionId($form, $options = array())
 {
     $elementName = isset($options['name']) ? $options['name'] : 'job_function_id';
     $modelField = isset($options['modelfield']) ? $options['modelfield'] : 'job_function_id';
     $form->addElement('select', $elementName, array('filters' => array('StringTrim'), 'label' => isset($options['label']) ? $options['label'] : 'Job function', 'dimension' => isset($options['dimension']) ? $options['dimension'] : 6, 'placeholder' => 'Choose a job function', 'required' => isset($options['required']) ? $options['required'] : true, 'value' => $this->_model ? $this->_model->{$modelField} : ''));
     $el = $form->getElement($elementName);
     $firstvaluenull = isset($options['firstvaluenull']) ? $options['firstvaluenull'] : true;
     if ($firstvaluenull) {
         $el->addMultiOption(null, null);
     }
     /**
      * Add job functions
      */
     $jfd = new Staff_Domain_Jobfunction();
     $jf = $jfd->getAll('name');
     foreach ($jf as $item) {
         $el->addMultiOption($item->getId(), $item->getName());
     }
     // set value
     if ($this->_model && $this->_model->{$modelField}) {
         $el->setValue($this->_model->{$modelField});
     } else {
         $el->setValue(null);
     }
 }
开发者ID:brunopbaffonso,项目名称:ongonline,代码行数:39,代码来源:Util.php

示例6: ajouterAction

 public function ajouterAction()
 {
     $form = new Zend_Form();
     $form->setMethod('post');
     $form->addElement('text', 'TITRE_E', array('label' => 'Titre de l\'émission : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'THEME', array('label' => 'Theme : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'ANIMATEURS', array('label' => 'Animateur(s) : ', 'required' => true, 'filters' => array('StringTrim')));
     $form->addElement('text', 'DUREE', array('label' => 'Durée de l\'émission : ', 'required' => true, 'filters' => array('Int')));
     $form->addElement('text', 'PATH_E', array('label' => 'Lien vers le podcast : ', 'required' => false, 'filters' => array('StringTrim')));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel('Ajouter');
     $form->addElement($submit);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $dba = Zend_Registry::get('dba');
             $datas = array('THEME' => $formData["THEME"], 'ANIMATEURS' => $formData["ANIMATEURS"], 'DUREE' => $formData["DUREE"], 'TITRE_E' => $formData["TITRE_E"], 'PATH_E' => $formData["PATH_E"]);
             $dba->beginTransaction();
             try {
                 $dba->insert('EMISSION', $datas);
                 $dba->commit();
             } catch (Exception $e) {
                 $dba->rollBack();
                 echo $e->getMessage();
             }
             $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     }
     $this->view->form = $form;
 }
开发者ID:nikoul,项目名称:Projet-PHP-WebRadio,代码行数:32,代码来源:EmissionController.php

示例7: getFormLogin

 private function getFormLogin()
 {
     $form = new Zend_Form(array('disableLoadDefaultDecorators' => true));
     $email = new Zend_Form_Element_Text('login', array('disableLoadDefaultDecorators' => true));
     $email->addDecorator('ViewHelper');
     $email->addDecorator('Errors');
     $email->setRequired(true);
     $email->setAttrib('class', 'form-control');
     $email->setAttrib('placeholder', 'Login');
     $email->setAttrib('required', 'required');
     $email->setAttrib('autofocus', 'autofocus');
     $password = new Zend_Form_Element_Password('password', array('disableLoadDefaultDecorators' => true));
     $password->addDecorator('ViewHelper');
     $password->addDecorator('Errors');
     $password->setRequired(true);
     $password->setAttrib('class', 'form-control');
     $password->setAttrib('placeholder', 'Hasło');
     $password->setAttrib('required', 'required');
     $password->setAttrib('autofocus', 'autofocus');
     $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true));
     $submit->setAttrib('class', 'btn btn-lg btn-primary btn-block');
     $submit->setOptions(array('label' => 'Zaloguj'));
     $submit->addDecorator('ViewHelper')->addDecorator('Errors');
     $form->addElement($email)->addElement($password)->addElement($submit);
     return $form;
 }
开发者ID:dafik,项目名称:zf-scaffold,代码行数:26,代码来源:ControllerAuthLogin.php

示例8: createAssetstoreForm

 /** Create assetstore form */
 public function createAssetstoreForm()
 {
     $form = new Zend_Form();
     $action = $this->webroot . '/assetstore/add';
     $form->setAction($action);
     $form->setName('assetstoreForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'assetstoreForm');
     // Name of the assetstore
     $inputDirectory = new Zend_Form_Element_Text('name', array('label' => $this->t('Give a name'), 'id' => 'assetstorename'));
     $inputDirectory->setRequired(true);
     $form->addElement($inputDirectory);
     // Input directory
     $basedirectory = new Zend_Form_Element_Text('basedirectory', array('label' => $this->t('Pick a base directory'), 'id' => 'assetstoreinputdirectory'));
     $basedirectory->setRequired(true);
     $form->addElement($basedirectory);
     // Assetstore type
     $assetstoretypes = array('0' => $this->t('Managed by MIDAS'), '1' => $this->t('Remotely linked'));
     // Amazon support is not yet implemented, don't present it as an option
     //                          '2' => $this->t('Amazon S3'));
     $assetstoretype = new Zend_Form_Element_Select('assetstoretype', array('id' => 'assetstoretype'));
     $assetstoretype->setLabel('Select a type')->setMultiOptions($assetstoretypes);
     // Add a loading image
     $assetstoretype->setDescription('<div class="assetstoreLoading" style="display:none"><img src="' . $this->webroot . '/core/public/images/icons/loading.gif"/></div>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $form->addElement($assetstoretype);
     // Submit
     $addassetstore = new Zend_Form_Element_Submit('addassetstore', $this->t('Add this assetstore'));
     $form->addElement($addassetstore);
     return $form;
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:31,代码来源:AssetstoreForm.php

示例9: editAction

 public function editAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $userForm = new Zend_Form($configForm->user);
     $userId = $this->getRequest()->getParam('id', null);
     if ($this->getRequest()->isPost()) {
         if ($userForm->isValid($_POST)) {
             try {
                 $values = $userForm->getValues();
                 unset($values['password_repeat']);
                 $userId = $this->userRepository->saveEntity($values);
                 $this->_helper->systemMessages('notice', 'Nutzer erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Nutzer konnte nicht gespeichert werden');
             }
         }
     } else {
         try {
             $entity = $this->userRepository->fetchEntity($userId);
             $userForm->populate($entity->toArray());
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage(), 404);
         }
     }
     $userForm->setAction('/admin/user/edit/' . $userId);
     $this->view->form = $userForm;
 }
开发者ID:kromeyer,项目名称:MMK-Newsroom,代码行数:29,代码来源:UserController.php

示例10: addSubForm

 /**
  * add subform element to stack
  *
  * @param Zend_Form $form
  * @return Centurion_Form_DisplayGroup
  */
 public function addSubForm(Zend_Form $form)
 {
     $this->_subForms[$form->getName()] = $form;
     $this->_orders[$form->getName()] = count($this->_order);
     $this->_groupUpdated = true;
     return $this;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:13,代码来源:DisplayGroup.php

示例11: setForm

		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;
		}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:34,代码来源:QuangcaoController.php

示例12: loginAction

 public function loginAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $loginForm = new \Zend_Form($configForm->login);
     if ($this->getRequest()->isPost()) {
         if ($loginForm->isValid($_POST)) {
             try {
                 $auth = $this->getInvokeArg('bootstrap')->auth;
                 $auth->setIdentity($loginForm->getValue('login'))->setCredential($loginForm->getValue('password'));
                 $result = \Zend_Auth::getInstance()->authenticate($auth);
                 if ($result->isValid()) {
                     $this->_redirect('/admin');
                 } else {
                     $this->_helper->systemMessages('error', 'Anmeldung verweigert');
                 }
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Fehler bei der Anmeldung');
             }
         }
     }
     $loginForm->setAction('/login');
     $this->view->form = $loginForm;
 }
开发者ID:kromeyer,项目名称:MMK-Newsroom,代码行数:25,代码来源:IndexController.php

示例13: nodeSave

 /**
  * Hook for node save - save parent (category)
  *
  * @param Zend_Form $form
  * @param array $arguments
  */
 public function nodeSave(&$form, &$arguments)
 {
     $item = array_shift($arguments);
     $arguments = $form->getValues();
     if (isset($arguments['rewrite_path'])) {
         $router = Zend_Controller_Front::getInstance()->getRouter();
         $default_url = $router->assemble(array('id' => $item->id), $item->type);
         $factory = new Rewrite_Path_Factory();
         $path = $factory->find($item->id)->current();
         if ($arguments['rewrite_path'] == $default_url) {
             if ($path) {
                 $path->delete();
             }
         } else {
             if (!$path) {
                 $path = $factory->createRow();
                 $path->nid = $item->id;
             }
             if ($arguments['rewrite_path'] != $path->path) {
                 $path->path = $arguments['rewrite_path'];
                 $path->save();
             }
         }
     }
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:31,代码来源:Node.php

示例14: loadFromForm

 public function loadFromForm(Zend_Form $form)
 {
     $this->title = $form->getTitle();
     $this->body = $form->getBody();
     $this->permalink = $form->getPermalink();
     $this->owner = $form->getOwner();
 }
开发者ID:radalin,项目名称:zf-examples,代码行数:7,代码来源:Post.php

示例15: saveFormData

 public function saveFormData(Zend_Form $form)
 {
     $item = $this->_model;
     $item->setOptions($form->getValues());
     if ($this->_request->getParam('contentMarkdown')) {
         $context_html = Michelf\MarkdownExtra::defaultTransform($this->_request->getParam('contentMarkdown'));
         $item->setContentHtml($context_html);
     }
     $fullPath = $this->_request->getParam('path');
     if ($this->_request->getParam('parentId') != 0) {
         $parentCategory = $this->_modelMapper->find($this->_request->getParam('parentId'), new Pipeline_Model_PipelineCategories());
         if ($parentCategory) {
             $fullPath = $parentCategory->getFullPath();
         }
     }
     $item->setFullPath($fullPath);
     $this->setMetaData($item);
     $this->getModelMapper()->save($item);
     if ($item->getId() && $item->getId() != '') {
         $id = $item->getId();
     } else {
         $id = $this->getModelMapper()->getDbTable()->getAdapter()->lastInsertId();
     }
     $item = $this->getModelMapper()->find($id, $this->getModel());
     foreach ($form->getElements() as $key => $element) {
         if ($element instanceof Zend_Form_Element_File && $element->isUploaded()) {
             $item = $this->saveUploadFile($element, $item);
         }
     }
     return $item;
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:31,代码来源:PipelineCategoriesController.php


注:本文中的Zend_Form类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。