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


PHP Zend_Filter_Input::getInvalid方法代码示例

本文整理汇总了PHP中Zend_Filter_Input::getInvalid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Input::getInvalid方法的具体用法?PHP Zend_Filter_Input::getInvalid怎么用?PHP Zend_Filter_Input::getInvalid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Filter_Input的用法示例。


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

示例1: testValidatorScalarInvalid

 public function testValidatorScalarInvalid()
 {
     $data = array('month' => '6abc ');
     $filters = array('month' => array());
     $validators = array('month' => 'digits');
     $input = new Zend_Filter_Input($filters, $validators, $data);
     $invalid = $input->getInvalid();
     $msg = $invalid['month'][0];
     $this->assertEquals("'6abc ' contains not only digit characters", $msg);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:InputTest.php

示例2: testValidatorGetInvalid

 public function testValidatorGetInvalid()
 {
     $data = array('month' => '6abc ');
     $validators = array('month' => 'digits', 'field2' => array('digits', 'presence' => 'required'));
     $input = new Zend_Filter_Input(null, $validators, $data);
     $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true');
     $this->assertTrue($input->hasInvalid(), 'Expected hasInvalid() to return true');
     $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
     $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
     $messages = $input->getMessages();
     $invalid = $input->getInvalid();
     $missing = $input->getMissing();
     $this->assertType('array', $messages);
     $this->assertEquals(array('month', 'field2'), array_keys($messages));
     $this->assertType('array', $invalid);
     $this->assertEquals(array('month'), array_keys($invalid));
     $this->assertType('array', $missing);
     $this->assertEquals(array('field2'), array_keys($missing));
     $this->assertEquals(array_merge($invalid, $missing), $messages);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:20,代码来源:InputTest.php

示例3: fromFilter

 /**
  * Creates a Conjoon_Error_Form based on the fields that where marked as
  * errorneous in the passed filter-instance.
  *
  * @param Zend_Filter_Input $filter
  * @param Zend_Filter_Exception $e
  *
  * @return Conjoon_Error_Form
  */
 public static function fromFilter(Zend_Filter_Input $filter, Zend_Filter_Exception $e)
 {
     $error = self::fromException($e, 'Conjoon_Error_Form');
     $fields = array();
     if ($filter->hasMissing()) {
         foreach ($filter->getMissing() as $f => $mes) {
             $fields[$f] = array_values($mes);
         }
     } else {
         if ($filter->hasInvalid()) {
             foreach ($filter->getInvalid() as $f => $mes) {
                 $fields[$f] = array_values($mes);
             }
         }
     }
     $error->setMessage("Error in user input. The following fields " . "where missing or contained invalid data: " . implode('; ', array_keys($fields)));
     $error->setLevel(self::LEVEL_WARNING);
     $error->setFields($fields);
     return $error;
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:29,代码来源:Error.php

示例4: _saveNewsArticle

 /**
  * Save changes to an existing news article, or save a new article in the database. If a new article the function will return the ID.
  *
  * @return int
  */
 private function _saveNewsArticle()
 {
     // First of all we need to validate and sanitise the input from the form
     $requiredText = new Zend_Validate();
     $requiredText->addValidator(new Zend_Validate_NotEmpty());
     // $requiredText->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => true)));
     $filters = array('id' => 'Digits', 'newsTitle' => 'StringTrim', 'newsDate' => 'StringTrim', 'categoryList' => 'StringTrim');
     $validators = array('id' => array('allowEmpty' => true), 'newsTitle' => $requiredText, 'newsContent' => array('allowEmpty' => true), 'newsDate' => 'NotEmpty', 'categoryList' => array('allowEmpty' => true));
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     if ($input->isValid()) {
         // Data is all valid, formatted and sanitized so we can save it in the database
         $newsArticle = new Datasource_Cms_News();
         if (!$input->id) {
             // This is a new article so we need to create a new ID
             $newsID = $newsArticle->addNew($input->newsTitle, $input->newsDate, $input->getUnescaped('newsContent'));
         } else {
             // This is an existing article so we can just update the data
             $newsArticle->saveChanges($input->id, $input->newsTitle, $input->newsDate, $input->getUnescaped('newsContent'));
             $newsID = $input->id;
         }
         // Now we need to link the page to the categories selected
         $categoryList = $input->categoryList;
         $newsArticle->saveCategories($newsID, $categoryList);
         // Changes saved - so send them back with a nice success message
         $this->_helper->getHelper('FlashMessenger')->addMessage(array('saved' => true));
         $this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/news/edit?id=' . $newsID);
     } else {
         // Invalid data in form
         print_r($_POST);
         print_r($input->getErrors());
         print_r($input->getInvalid());
     }
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:38,代码来源:NewsController.php


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