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


PHP FormValidator::isValid方法代码示例

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


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

示例1: indexAction

 /**
  * Handles requested "/" route
  */
 public function indexAction()
 {
     // handle contact form
     if (!empty($_POST['form_submit'])) {
         $formValidator = new FormValidator($_POST['form'], $this->view);
         // if there were no errors
         if ($formValidator->isValid()) {
             // format user submitted data
             $data = array();
             $data[] = '<table>';
             foreach ($_POST['form'] as $field => $value) {
                 $data[] = '<tr><th>' . ucwords(str_replace(array('-', '_'), ' ', $field)) . '</th><td>' . nl2br($value) . '</td></tr>';
             }
             $data[] = '</table>';
             // send message
             $mailer = new Mailer();
             $result = $mailer->sendSystemMessage(implode("\n", $data), $_POST['form_submit']);
             if ($result) {
                 $this->router->redirect('/thanks');
                 die;
             }
         } else {
             $this->errorMessages = $formValidator->getFormattedErrors();
         }
     }
 }
开发者ID:ArtifexTech,项目名称:life-jacket,代码行数:29,代码来源:Controller.php

示例2: isValid

 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid()
 {
     // check if generally formatted as a date and if required
     if (!parent::isValid()) {
         return false;
     }
     // if parent::isValid is true and $value is empty, this value is optional
     $fieldValue = $this->getFieldValue();
     if (!$fieldValue) {
         return true;
     }
     $validator = parent::getValidator();
     return $validator->isValid($fieldValue, $this->_scopeMin, $this->_scopeMax);
 }
开发者ID:jprk,项目名称:pkp-lib,代码行数:19,代码来源:FormValidatorDate.inc.php

示例3: testIsValid

 /**
  * @covers FormValidator::isValid
  */
 public function testIsValid()
 {
     // We don't need to test the case where a validator is set, this
     // is sufficiently tested by the other FormValidator* tests.
     // Test default validation (without internal validator set and optional values)
     $formValidator = new FormValidator($this->form, 'testData', FORM_VALIDATOR_OPTIONAL_VALUE, 'some.message.key');
     self::assertTrue($formValidator->isValid());
     // Test default validation (without internal validator set and required values)
     $formValidator = new FormValidator($this->form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key');
     self::assertFalse($formValidator->isValid());
     $this->form->setData('testData', array());
     $formValidator = new FormValidator($this->form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key');
     self::assertFalse($formValidator->isValid());
     $this->form->setData('testData', 'some value');
     $formValidator = new FormValidator($this->form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key');
     self::assertTrue($formValidator->isValid());
     $this->form->setData('testData', array('some value'));
     $formValidator = new FormValidator($this->form, 'testData', FORM_VALIDATOR_REQUIRED_VALUE, 'some.message.key');
     self::assertTrue($formValidator->isValid());
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:23,代码来源:FormValidatorTest.php


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