• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FormValidator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getSearchForm

 /**
  * @param string $url
  * @return \FormValidator
  */
 private function getSearchForm($url)
 {
     $form = new \FormValidator('search-form', 'get', $url, null, array('class' => 'form-inline'));
     $form->addElement('text', 'keyword');
     $form->addElement('button', 'submit', get_lang('Search'));
     return $form;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:11,代码来源:AdminController.php


示例2: addPhotoModel

 function addPhotoModel($photoForm, $albumId)
 {
     $formObjRaw = new FormDTO(ADD_PHOTO_FORM, $photoForm);
     $responseDTO = new ResponseDTO(ADD_PHOTO_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(ADD_PHOTO_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[ADD_PHOTO_FORM . PHOTO], $albumId, ADD_PHOTO_FORM, $formDataObj[ADD_PHOTO_FORM . LATITUDE], $formDataObj[ADD_PHOTO_FORM . LONGITUDE]);
             if (get_class($uploadedPhoto) === PHOTODTO) {
                 DataModelUtils::notifyAction($uploadedPhoto->getPhotoId() . SEPARATOR . $uploadedPhoto->getPhotoUrl() . SEPARATOR . $albumId, ADD_PHOTO_FORM);
                 return $uploadedPhoto;
             } else {
                 $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto");
             }
         } else {
             if (array_key_exists(PHOTO, $validationError)) {
                 $responseDTO->setErrField(PHOTO, $validationError[PHOTO]);
             }
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:sbadi,项目名称:shareatrip,代码行数:30,代码来源:Photo_model.php


示例3: openid_form

function openid_form()
{
    $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login'));
    $form->addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input'));
    $form->addElement('button', 'submit', get_lang('Login'));
    return $form->return_form();
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:7,代码来源:login.php


示例4: redirectPostRequest

 /**
  * Controls direction of inbound POST data by intercepting it and sending it
  * to the correct model and then loads the correct views
  *
  * Note - need a way to determine the amount of input fields and their types, 
  * 		which will help in determing what error checking needs to be done.
  * 		This should be a model that parses out the POST array
  * 
  * @return [type] [description]
  */
 public function redirectPostRequest()
 {
     // send form data to the model
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // invoke form validator model
         $FormValidator = new FormValidator();
         $FormValidator->validateFormData($_POST);
         // get errors array
         $errorsArray = $FormValidator->getErrorsArray();
         // determine if an error was flagged due to illegal user input
         if (filter_by_value($errorsArray, 'error', '1')) {
             // debug
             // print_var($errorsArray);
             // echo "Error exists";
             // render errors to client
             require 'application/views/view.render_form_errors.php';
             echo "HERE IS THE VIEW" . "<br>";
         } else {
             // require APP_PATH . 'controller/' . $this->url_controller . '.php';
             // $this->url_controller = new $this->url_controller();
             // redirect user to a success page
             // header('Location: success_page.php');
         }
     }
 }
开发者ID:puiu91,项目名称:Learning-MVC,代码行数:35,代码来源:FormController.php


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


示例6: render

 /**
  * @param FormValidator $form
  * @param array $questionData
  * @param array $answers
  */
 public function render(FormValidator $form, $questionData = array(), $answers = '')
 {
     $name = 'question' . $questionData['question_id'];
     $form->addSelect($name, null, $questionData['options']);
     if (!empty($answers)) {
         $form->setDefaults([$name => $answers]);
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:13,代码来源:ch_dropdown.php


示例7: getSearchForm

 /**
  * @return FormValidator
  */
 private function getSearchForm()
 {
     $form = new FormValidator('form-search', 'post', api_get_self() . '?action=subscribe&amp;hidden_links=0', null, array('class' => 'form-search'));
     $form->addElement('hidden', 'search_course', '1');
     $form->addElement('text', 'search_term');
     $form->addElement('button', 'submit', get_lang('Search'));
     return $form;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:11,代码来源:courses_controller.php


示例8: FormValidator

 /** @test */
 public function バリデーション違反があれば、違反したルールを返すこと()
 {
     $validator = new FormValidator();
     $validator->addRule(FormValidator::ZIP_CODE, 'xxx-1111', '郵便番号に誤りがあります')->addRule(FormValidator::DATE, '2015-11-11', '日付に誤りがあります');
     $errors = $validator->valid();
     $expected = [];
     $expected[] = new ValidateRule(FormValidator::ZIP_CODE, 'xxx-1111', '郵便番号に誤りがあります');
     // objectの比較のためassertEquals
     $this->assertEquals($expected, $errors);
 }
开发者ID:hamuhamu,项目名称:ChainValidator,代码行数:11,代码来源:FormValidatorTest.php


示例9: testInteger

 public function testInteger()
 {
     $profile = array('constraints' => array('field1' => array('required' => 1, 'integer' => 1), 'field2' => array('integer' => 1), 'field3' => array('integer' => 1), 'field4' => array('integer' => 1), 'field5' => array('integer' => 1)));
     $data = array('field1' => '5', 'field2' => 10, 'field3' => 'asdf', 'field4' => '5.1', 'field5' => 5.1);
     $validator = new FormValidator();
     $errors = $validator->validate($data, $profile);
     $this->assertEquals($errors, array('field3 is invalid.', 'field4 is invalid.', 'field5 is invalid.'));
     $this->assertEquals($validator->valid, array('field1', 'field2'));
     $this->assertEquals($validator->invalid, array('field3', 'field4', 'field5'));
     $this->assertEquals($validator->missing, array());
 }
开发者ID:lmcro,项目名称:fcms,代码行数:11,代码来源:FormValidatorTest.php


示例10: render

 /**
  * @param FormValidator $form
  * @param array $questionData
  * @param string $answers
  */
 public function render(FormValidator $form, $questionData = array(), $answers = '')
 {
     if (is_array($answers)) {
         $content = implode('', $answers);
     } else {
         $content = $answers;
     }
     $name = 'question' . $questionData['question_id'];
     $form->addTextarea($name, null);
     $form->setDefaults([$name => $answers]);
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:16,代码来源:ch_comment.php


示例11: render

 /**
  * @param FormValidator $form
  * @param array $questionData
  * @param array $answers
  */
 public function render(FormValidator $form, $questionData = array(), $answers = '')
 {
     $options = array('--' => '--');
     foreach ($questionData['options'] as $key => &$value) {
         $options[$key] = $value;
     }
     $name = 'question' . $questionData['question_id'];
     $form->addSelect($name, null, $options);
     if (!empty($answers)) {
         $form->setDefaults([$name => $answers]);
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:17,代码来源:ch_percentage.php


示例12: formTochuc

 public function formTochuc()
 {
     $validator = new FormValidator();
     $valid = array();
     $valid['NAME'] = array('req' => "Please fill in Name");
     $valid['LOAIHINHBIENCHE'] = array('req' => "Please fill in Name");
     foreach ($valid as $input => $aRow) {
         foreach ($aRow as $key => $value) {
             $validator->addValidation($input, $key, $value);
         }
     }
     return $validator;
 }
开发者ID:phucdnict,项目名称:cbcc_05062015,代码行数:13,代码来源:Validate.php


示例13: ch_qti2_display_form

/**
 * This function displays the form for import of the zip file with qti2
 */
function ch_qti2_display_form()
{
    $name_tools = get_lang('ImportQtiQuiz');
    $form = '<div class="actions">';
    $form .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'exercice/exercise.php?show=test&' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>';
    $form .= '</div>';
    $formValidator = new FormValidator('qti_upload', 'post', api_get_self() . "?" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data'));
    $formValidator->addElement('header', $name_tools);
    $formValidator->addElement('file', 'userFile', get_lang('DownloadFile'));
    $formValidator->addButtonImport(get_lang('Upload'));
    $form .= $formValidator->returnForm();
    echo $form;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:16,代码来源:qti2.php


示例14: createAnswersForm

 /**
  * function which redefine Question::createAnswersForm
  * @param FormValidator $form
  */
 function createAnswersForm($form)
 {
     $form->addElement('text', 'weighting', get_lang('Weighting'), array('class' => 'span1'));
     global $text, $class;
     // setting the save button here and not in the question class.php
     $form->addButtonSave($text, 'submitQuestion');
     if (!empty($this->id)) {
         $form->setDefaults(array('weighting' => float_format($this->weighting, 1)));
     } else {
         if ($this->isContent == 1) {
             $form->setDefaults(array('weighting' => '10'));
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:18,代码来源:oral_expression.class.php


示例15: openid_form

function openid_form()
{
    //get_lang('OpenIdAuthentication')
    $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login'));
    $form->addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input'));
    $form->addElement('button', 'submit', get_lang('Login'));
    return $form->return_form();
    /*
     return '<label for="openid_url">'.get_lang('OpenIDURL').' <a href="main/auth/openid/whatis.php" title="'.get_lang('OpenIDWhatIs').'">'.Display::return_icon('info3.gif',get_lang('Info')).'</a></label>
     <input type="text" id="openid_url" name="openid_url" style="background: url(main/img/openid_small_logo.png) no-repeat; background-color: #fff; background-position: 0 50%; padding-left:18px;" value="http://"></input>
    * <input type="submit" name="openid_login" value="'.get_lang('Enter').'" /><br /><br /></form></div>';
    *
    */
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:14,代码来源:login.php


示例16: render

 /**
  * @param FormValidator $form
  * @param array $questionData
  * @param array $answers
  */
 public function render(FormValidator $form, $questionData = array(), $answers = null)
 {
     if (is_array($questionData['options'])) {
         if ($questionData['display'] == 'vertical') {
             $class = 'radio';
         } else {
             $class = 'radio-inline';
         }
         $name = 'question' . $questionData['question_id'];
         $form->addRadio($name, null, $questionData['options'], ['radio-class' => $class, 'label-class' => $class]);
         if (!empty($answers)) {
             $form->setDefaults([$name => $answers]);
         }
     }
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:20,代码来源:ch_yesno.php


示例17: FormValidatorReCaptcha

 /**
  * Constructor.
  * @param $form object
  * @param $userIp string IP address of user request
  * @param $message string Key of message to display on mismatch
  */
 function FormValidatorReCaptcha(&$form, $challengeField, $responseField, $userIp, $message)
 {
     parent::FormValidator($form, $challengeField, FORM_VALIDATOR_REQUIRED_VALUE, $message);
     $this->_challengeField = $challengeField;
     $this->_responseField = $responseField;
     $this->_userIp = $userIp;
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:13,代码来源:FormValidatorReCaptcha.inc.php


示例18: FormValidatorArray

 /**
  * Constructor.
  * @param $form Form the associated form
  * @param $field string the name of the associated field
  * @param $type string the type of check, either "required" or "optional"
  * @param $message string the error message for validation failures (i18n key)
  * @param $fields array all subfields for each item in the array, i.e. name[][foo]. If empty it is assumed that name[] is a data field
  */
 function FormValidatorArray(&$form, $field, $type, $message, $fields = array(), $subArray = false)
 {
     parent::FormValidator($form, $field, $type, $message);
     $this->_fields = $fields;
     $this->_subArray = $subArray;
     $this->_errorFields = array();
 }
开发者ID:elavaud,项目名称:hrp_ct,代码行数:15,代码来源:FormValidatorArray.inc.php


示例19: FormValidatorArrayRadios

 /**
  * Constructor.
  * @param $form Form the associated form
  * @param $field string the name of the associated field
  * @param $type string the type of check, either "required" or "optional"
  * @param $message string the error message for validation failures (i18n key)
  * @param $radiofields array all the radio buttons to check.
  * @param $twoDim boolean specify if if this is a 2 dimensional array
  */
 function FormValidatorArrayRadios(&$form, $field, $type, $message, $radiofields, $twoDim = false)
 {
     parent::FormValidator($form, $field, $type, $message);
     $this->twoDimenstion = $twoDim;
     $this->_radiofields = $radiofields;
     $this->_errorFields = array();
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:16,代码来源:FormValidatorArrayRadios.inc.php


示例20: FormValidatorCustom

 /**
  * Constructor.
  * The user function is passed the form data as its first argument and $additionalArguments, if set, as the remaining arguments. This function must return a boolean value.
  * @param $form Form the associated form
  * @param $field string the name of the associated field
  * @param $type string the type of check, either "required" or "optional"
  * @param $message string the error message for validation failures (i18n key)
  * @param $userFunction callable function the user function to use for validation
  * @param $additionalArguments array optional, a list of additional arguments to pass to $userFunction
  * @param $complementReturn boolean optional, complement the value returned by $userFunction
  */
 function FormValidatorCustom(&$form, $field, $type, $message, $userFunction, $additionalArguments = array(), $complementReturn = false)
 {
     parent::FormValidator($form, $field, $type, $message);
     $this->_userFunction = $userFunction;
     $this->_additionalArguments = $additionalArguments;
     $this->_complementReturn = $complementReturn;
 }
开发者ID:EreminDm,项目名称:water-cao,代码行数:18,代码来源:FormValidatorCustom.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FormVariables类代码示例发布时间:2022-05-23
下一篇:
PHP FormUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap