當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Form::isValid方法代碼示例

本文整理匯總了PHP中Zend_Form::isValid方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Form::isValid方法的具體用法?PHP Zend_Form::isValid怎麽用?PHP Zend_Form::isValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Form的用法示例。


在下文中一共展示了Zend_Form::isValid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveAction

 public function saveAction()
 {
     $this->getRequest()->isPost();
     $this->buildForm("admin/group/save");
     if ($this->gForm->isValid($_POST)) {
         $values = $this->gForm->getValues();
     }
     //Build Group Object
     $group = new Group();
     //Upload Logo
     if (copy($values['logo'], Zend_Registry::get('config')->files->logo->dir . DIRECTORY_SEPARATOR . basename($values['logo']))) {
         $values['logo'] = Zend_Registry::get('config')->files->logo->dir . "/" . basename($values['logo']);
     }
     //Convert polygon cordenates
     preg_match_all("/\\(([0-9\\.\\,\\-\\s]*)\\)[\\,]?/", $values['area_coords'], $rawcoords);
     foreach ($rawcoords[1] as $coord) {
         $cvalues = explode(",", $coord);
         $cobj = new stdClass();
         $cobj->lat = trim($cvalues[0]);
         $cobj->lng = trim($cvalues[1]);
         $coords[] = $cobj;
     }
     $values['area_coords'] = json_encode($coords);
     //Register Administrators
     $admins = explode(",", $values['admins']);
     foreach ($admins as $adm) {
         if ($adm != "") {
             $group->Admins[]->user_id = $adm;
         }
     }
     //Go through Activity Types
     $actvTypes = Doctrine_Query::create()->from('ActivityType')->orderBy("weight")->execute();
     foreach ($actvTypes as $atype) {
         $atype_key = "atype_" . $atype->atype;
         $aSource = new ActivitySource();
         $aSource->atype = $atype->atype;
         $aSource->target = $values[$atype_key];
         $group->ActivitySources[] = $aSource;
     }
     //populate group
     $group->fromArray($values);
     //Save Group
     $group->save();
     var_dump($values, $group->toArray());
     //Grab pre-saved venues and tie group_id
     $venues = Doctrine_Query::create()->from('Venue')->where("Venue.name LIKE ?", array($values['tmp_id'] . '%'))->execute();
     foreach ($venues as $venue) {
         $venue->name = str_replace($values['tmp_id'] . "_", "", $venue->name);
         $venue->group_id = $group->id;
         $venue->save();
     }
     $this->_helper->flashMessenger("Group added!");
     //$this->_helper->redirector('index');
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
 }
開發者ID:rdohms,項目名稱:ugDirectory,代碼行數:56,代碼來源:GroupController.php

示例2: isValid

 /**
  *
  * @param array $pParam
  * @return boolean
  */
 public function isValid($pParam)
 {
     foreach ($pParam as $f => $v) {
         $pParam[$f] = stripslashes($v);
     }
     return parent::isValid($pParam);
 }
開發者ID:BGCX262,項目名稱:zupal-svn-to-git,代碼行數:12,代碼來源:Form.php

示例3: 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

示例4: isValid

 public function isValid($formData = array())
 {
     if (isset($formData['property_postcode']) && '' != trim($formData['property_postcode'])) {
         $postcode = trim($formData['property_postcode']);
         $postcodeLookup = new Manager_Core_Postcode();
         $addresses = $postcodeLookup->getPropertiesByPostcode(preg_replace('/[^\\w\\ ]/', '', $postcode));
         $addressList = array('' => '--- please select ---');
         foreach ($addresses as $address) {
             $addressList[$address['id']] = $address['singleLineWithoutPostcode'];
         }
         $ins_address = $this->getElement('property_address');
         $ins_address->setMultiOptions($addressList);
         $validator = new Zend_Validate_InArray(array('haystack' => array_keys($addressList)));
         $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Insured address does not match with postcode'));
         $ins_address->addValidator($validator, true);
     }
     // If a value for an address lookup is present, the house name or number is not required
     if (isset($formData['is_foreign_address']) && 'Yes' == $formData['is_foreign_address']) {
         $this->getElement('property_postcode')->setRequired(false);
         $this->getElement('property_address')->setRequired(false);
     }
     if (isset($formData['property_postcode'])) {
         $this->getElement('property_number_name')->setRequired(false);
     }
     return parent::isValid($formData);
 }
開發者ID:AlexEvesDeveloper,項目名稱:hl-stuff,代碼行數:26,代碼來源:Residence.php

示例5: bookingAction

 /** THis is where they pick the duration */
 function bookingAction()
 {
     $this->layout('layout/layout-appointment-summary');
     $layoutViewModel = $this->layout();
     $progress = new ViewModel(['step' => 3]);
     $progress->setTemplate('application/progress');
     $layoutViewModel->addChild($progress, 'progress');
     $service = $this->serviceDataMapper()->find($this->params('service'));
     $durations = array();
     foreach ($service['durations'] as $duration) {
         $durations[$duration] = $this->durationLabels[$duration];
     }
     $form = new \Zend_Form();
     $form->addElement('radio', 'appointment_duration', array('label' => 'Appointment Duration', 'multiOptions' => $durations, 'separator' => ''));
     if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
         $url = $this->url()->fromRoute('make-booking', array('action' => 'booking2', 'duration' => $form->getValue('appointment_duration'), 'service' => $this->params('service'), 'day' => $this->params('day')));
         $this->redirect()->toUrl($url);
         return;
     }
     $this->viewParams['form'] = $form;
     $summary = new ViewModel($this->params()->fromRoute());
     $summary->setTemplate('application/summary');
     $layoutViewModel->addChild($summary, 'appointment_summary');
     $viewModel = new ViewModel($this->viewParams);
     $viewModel->setTemplate('application/booking');
     return $viewModel;
 }
開發者ID:mustafakarali,項目名稱:application,代碼行數:28,代碼來源:MakebookingController.php

示例6: isValid

 public function isValid($postData)
 {
     if (isset($postData['how_hear']) && $postData['how_hear'] == "Other") {
         $this->getElement('other')->setRequired(true);
     }
     return parent::isValid($postData);
 }
開發者ID:AlexEvesDeveloper,項目名稱:hl-stuff,代碼行數:7,代碼來源:Step3.php

示例7: isValid

 public function isValid($data)
 {
     // add email to request data as
     // isValid seems to remove any data currently loaded into the form
     $email = $this->getElement('email')->getValue();
     $data['email'] = $email;
     $validationResult = parent::isValid($data);
     // Perform login validation
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     if ($data['password'] != '') {
         // Process login
         $customerManager = new Manager_Core_Customer();
         $adapter = $customerManager->getAuthAdapter(array('email' => $data['email'], 'password' => $data['password']));
         $result = $auth->authenticate($adapter);
         if ($result->isValid()) {
             $email = $this->getElement('email');
             $newCustomer = $customerManager->getCustomerByEmailAddress($email->getValue());
             if ($newCustomer->getEmailValidated() !== true) {
                 $auth->clearIdentity();
                 $this->setDescription("Unfortunately you haven't validated your email address yet. We've sent you an email which includes a link to validate your My HomeLet account. You'll need to validate your account to continue. If you've not received your validation email or if you're unable to access your account, please call us on 0845 117 6000.");
                 return false;
             }
             $storage = $auth->getStorage();
             $storage->write($adapter->getResultRowObject(array('title', 'first_name', 'last_name', 'email_address', 'id')));
         } else {
             $this->setDescription('Your account details are incorrect, please try again');
             return false;
         }
     }
     // All valid above, return parents validation result
     return $validationResult;
 }
開發者ID:AlexEvesDeveloper,項目名稱:hl-stuff,代碼行數:33,代碼來源:Login.php

示例8: detailAction

 public function detailAction()
 {
     $newsUrl = $this->getRequest()->getParam('url', null);
     try {
         $news = $this->newsRepository->fetchEntityByUrl($newsUrl);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 404);
     }
     $this->view->headTitle($news->headline);
     $this->view->headMeta()->setName('description', $this->_helper->truncate($news->content, 255));
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $commentForm = new \Zend_Form($configForm->comment);
     if ($this->getRequest()->isPost()) {
         if ($commentForm->isValid($_POST)) {
             try {
                 $values = $commentForm->getValues();
                 unset($values['csrf']);
                 unset($values['firstname']);
                 # SpamDetection
                 $values['news'] = $news;
                 $this->commentRepository->saveEntity($values);
                 $commentForm->reset();
                 #$this->_helper->systemMessages('notice', 'Kommentar 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', 'Kommentar konnte nicht gespeichert werden');
             }
         }
     }
     $commentForm->setAction('/news/' . $newsUrl);
     $this->view->form = $commentForm;
     $this->view->news = $news;
 }
開發者ID:kromeyer,項目名稱:MMK-Newsroom,代碼行數:34,代碼來源:NewsController.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: 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

示例11: isValid

 public function isValid($data)
 {
     parent::isValid($data);
     $event = new Bc_Form_Event(Bc_Form_Event::FORM_VALIDATE_EVENT, $this);
     $event->dispatch();
     return !$this->_errorsExist;
 }
開發者ID:BGCX262,項目名稱:zsoc-svn-to-git,代碼行數:7,代碼來源:Form.php

示例12: removeAction

 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();
     }
 }
開發者ID:votanlean,項目名稱:Magento-Pruebas,代碼行數:33,代碼來源:LayoutController.php

示例13: isValid

 /**
  * Check if the entire form is valid
  *
  * @return boolean
  */
 public function isValid()
 {
     // Get the form data from the session
     $formData = $this->getFormSessionData();
     // Validate the form using the session data
     return $this->_form->isValid($formData);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:12,代碼來源:MultiPageForm.php

示例14: isValid

 /** @inheritdoc */
 public function isValid($data)
 {
     if ($this->csrfCheck) {
         $this->addCsrfProtection();
     }
     return parent::isValid($data);
 }
開發者ID:bombayworks,項目名稱:currycms,代碼行數:8,代碼來源:Form.php

示例15: isValid

 /**
  * Proxy to {@link Zend_Form::isValid()}.
  *
  * Calls {@link self::buildBootstrapErrorDecorators()} for
  * {@link parent::isValid()} returning false.
  *
  * @param array $values
  * @return bool
  * @throws Zend_Form_Exception
  */
 public function isValid($values)
 {
     $validCheck = parent::isValid($values);
     if ($validCheck === false) {
         $this->buildBootstrapErrorDecorators();
     }
     return $validCheck;
 }
開發者ID:dafik,項目名稱:dfi,代碼行數:18,代碼來源:Form.php


注:本文中的Zend_Form::isValid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。