本文整理汇总了PHP中FormValidator类的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator类的具体用法?PHP FormValidator怎么用?PHP FormValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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();
}
示例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');
}
}
}
示例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();
}
}
}
示例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]);
}
}
示例7: getSearchForm
/**
* @return FormValidator
*/
private function getSearchForm()
{
$form = new FormValidator('form-search', 'post', api_get_self() . '?action=subscribe&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;
}
示例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);
}
示例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());
}
示例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]);
}
示例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]);
}
}
示例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;
}
示例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;
}
示例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'));
}
}
}
示例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>';
*
*/
}