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


PHP form_get_errors函数代码示例

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


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

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $response = new AjaxResponse();
     if (form_get_errors($form_state)) {
         unset($form['#prefix'], $form['#suffix']);
         $status_messages = array('#theme' => 'status_messages');
         $output = drupal_render($form);
         $output = '<div>' . drupal_render($status_messages) . $output . '</div>';
         $response->addCommand(new HtmlCommand('#editor-link-dialog-form', $output));
     } else {
         $response->addCommand(new EditorDialogSave($form_state['values']));
         $response->addCommand(new CloseModalDialogCommand());
     }
     return $response;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:18,代码来源:EditorLinkDialog.php

示例2: testConfigForm

 /**
  * Submit the system_config_form ensure the configuration has expected values.
  */
 public function testConfigForm()
 {
     // Programmatically submit the given values.
     foreach ($this->values as $form_key => $data) {
         $values[$form_key] = $data['#value'];
     }
     $form_state = array('values' => $values);
     drupal_form_submit($this->form, $form_state);
     // Check that the form returns an error when expected, and vice versa.
     $errors = form_get_errors($form_state);
     $valid_form = empty($errors);
     $args = array('%values' => print_r($values, TRUE), '%errors' => $valid_form ? t('None') : implode(' ', $errors));
     $this->assertTrue($valid_form, format_string('Input values: %values<br/>Validation handler errors: %errors', $args));
     foreach ($this->values as $data) {
         $this->assertEqual($data['#value'], \Drupal::config($data['#config_name'])->get($data['#config_key']));
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:20,代码来源:SystemConfigFormTestBase.php

示例3: update

 /**
  * 
  * Do the actual update - passes the update to the plugin's process functions
  */
 function update()
 {
     if (function_exists($this->plugin['process'])) {
         $this->plugin['process']($this);
     }
     // Are there any form errors?
     if ($errors = form_get_errors()) {
         foreach ($errors as $error) {
             // Form errors will apply for all entities
             foreach ($this->entities as $entity) {
                 list($id) = entity_extract_ids($this->entity_type, $entity);
                 $this->set_error($id, $error);
             }
         }
     }
     return $this->get_result();
 }
开发者ID:acquiau-2015,项目名称:acquiau-site,代码行数:21,代码来源:handler.class.php

示例4: submitForm

 /**
  * Helper function used to programmatically submit the form defined in
  * form_test.module with the given values.
  *
  * @param $values
  *   An array of field values to be submitted.
  * @param $valid_input
  *   A boolean indicating whether or not the form submission is expected to
  *   be valid.
  */
 private function submitForm($values, $valid_input)
 {
     // Programmatically submit the given values.
     $form_state = new FormState(array('values' => $values));
     \Drupal::formBuilder()->submitForm('\\Drupal\\form_test\\Form\\FormTestProgrammaticForm', $form_state);
     // Check that the form returns an error when expected, and vice versa.
     $errors = form_get_errors($form_state);
     $valid_form = empty($errors);
     $args = array('%values' => print_r($values, TRUE), '%errors' => $valid_form ? t('None') : implode(' ', $errors));
     $this->assertTrue($valid_input == $valid_form, format_string('Input values: %values<br />Validation handler errors: %errors', $args));
     // We check submitted values only if we have a valid input.
     if ($valid_input) {
         // By fetching the values from $form_state['storage'] we ensure that the
         // submission handler was properly executed.
         $stored_values = $form_state['storage']['programmatic_form_submit'];
         foreach ($values as $key => $value) {
             $this->assertEqual($stored_values[$key], $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
         }
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:ProgrammaticTest.php

示例5: checkUserNameEmailExists

 /**
  * Check if username and email exists in the drupal db
  *
  * @params $params    array   array of name and mail values
  * @params $errors    array   array of errors
  * @params $emailName string  field label for the 'email'
  *
  * @return void
  */
 static function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email')
 {
     $config = CRM_Core_Config::singleton();
     $dao = new CRM_Core_DAO();
     $name = $dao->escape(CRM_Utils_Array::value('name', $params));
     $email = $dao->escape(CRM_Utils_Array::value('mail', $params));
     $errors = form_get_errors();
     if ($errors) {
         // unset drupal messages to avoid twice display of errors
         unset($_SESSION['messages']);
     }
     if (!empty($params['name'])) {
         if ($nameError = user_validate_name($params['name'])) {
             $errors['cms_name'] = $nameError;
         } else {
             $uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(':name' => $params['name']))->fetchField();
             if ((bool) $uid) {
                 $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', array(1 => $params['name']));
             }
         }
     }
     if (!empty($params['mail'])) {
         if ($emailError = user_validate_mail($params['mail'])) {
             $errors[$emailName] = $emailError;
         } else {
             $uid = db_query("SELECT uid FROM {users} WHERE mail = :mail", array(':mail' => $params['mail']))->fetchField();
             if ((bool) $uid) {
                 $resetUrl = $config->userFrameworkBaseURL . 'user/password';
                 $errors[$emailName] = ts('The email address %1 is already registered. <a href="%2">Have you forgotten your password?</a>', array(1 => $params['mail'], 2 => $resetUrl));
             }
         }
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:42,代码来源:Drupal.php

示例6: ctools_export_ui_edit_item_wizard_form_validate

/**
 * Validate handler for ctools_export_ui_edit_item_wizard_form.
 */
function ctools_export_ui_edit_item_wizard_form_validate(&$form, &$form_state)
{
    $method = 'edit_form_' . $form_state['step'] . '_validate';
    if (!method_exists($form_state['object'], $method)) {
        $method = 'edit_form_validate';
    }
    $form_state['object']->{$method}($form, $form_state);
    // Additionally, if there were no errors from that, and we're finishing,
    // perform a final validate to make sure everything is ok.
    if (isset($form_state['clicked_button']['#wizard type']) && $form_state['clicked_button']['#wizard type'] == 'finish' && !form_get_errors()) {
        $form_state['object']->edit_finish_validate($form, $form_state);
    }
}
开发者ID:kennygrage,项目名称:dynastyDish,代码行数:16,代码来源:ctools_export_ui.class.php

示例7: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, array &$form_state)
 {
     $form_state['handler']->validateOptionsForm($form['options'], $form_state);
     if (form_get_errors($form_state)) {
         $form_state['rerender'] = TRUE;
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:ConfigHandler.php

示例8: asf_ajax_login_callback

function asf_ajax_login_callback($form, &$form_state)
{
    // if errors, return the form
    if (form_get_errors()) {
        $msg = 'Sorry, unrecognized username or password.';
        for ($i = 0; $i < count($_SESSION['messages']['error']); $i++) {
            if (strpos($_SESSION['messages']['error'][$i], $msg) !== false) {
                $_SESSION['messages']['error'][$i] = $msg;
                break;
            }
        }
        $form_state['rebuild'] = TRUE;
        return $form;
    }
    // this performs the actual login
    user_login_submit($form, $form_state);
    // this performs a redirection
    $path = $form_state["redirect"] . "/subscriptions";
    ctools_include('ajax');
    ctools_add_js('ajax-responder');
    $commands[] = ctools_ajax_command_redirect($path);
    print ajax_render($commands);
    exit;
}
开发者ID:petergiesin,项目名称:asfitness,代码行数:24,代码来源:template.php

示例9: tfd_form_get_errors

function tfd_form_get_errors()
{
    $errors = form_get_errors();
    if (!empty($errors)) {
        $newErrors = array();
        foreach ($errors as $key => $error) {
            $newKey = str_replace('submitted][', 'submitted[', $key);
            if ($newKey !== $key) {
                $newKey = $newKey . ']';
            }
            $newErrors[$newKey] = $error;
        }
        $errors = $newErrors;
    }
    return $errors;
}
开发者ID:sulav,项目名称:TFD7,代码行数:16,代码来源:Extension.php

示例10: submitConfigurationForm

 /**
  * {@inheritdoc}
  *
  * Most block plugins should not override this method. To add submission
  * handling for a specific block type, override BlockBase::blockSubmit().
  *
  * @see \Drupal\block\BlockBase::blockSubmit()
  */
 public function submitConfigurationForm(array &$form, array &$form_state)
 {
     // Process the block's submission handling if no errors occurred only.
     if (!form_get_errors($form_state)) {
         $this->configuration['label'] = $form_state['values']['label'];
         $this->configuration['label_display'] = $form_state['values']['label_display'];
         $this->configuration['provider'] = $form_state['values']['provider'];
         $this->configuration['cache'] = $form_state['values']['cache'];
         foreach ($this->getVisibilityConditions() as $condition_id => $condition) {
             // Allow the condition to submit the form.
             $condition_values = array('values' => &$form_state['values']['visibility'][$condition_id]);
             $condition->submitConfigurationForm($form, $condition_values);
         }
         $this->blockSubmit($form, $form_state);
     }
 }
开发者ID:shumer,项目名称:blog,代码行数:24,代码来源:BlockBase.php

示例11: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $response = new AjaxResponse();
     // Convert any uploaded files from the FID values to data-editor-file-uuid
     // attributes.
     if (!empty($form_state['values']['fid'][0])) {
         $file = file_load($form_state['values']['fid'][0]);
         $file_url = file_create_url($file->getFileUri());
         // Transform absolute image URLs to relative image URLs: prevent problems
         // on multisite set-ups and prevent mixed content errors.
         $file_url = file_url_transform_relative($file_url);
         $form_state['values']['attributes']['src'] = $file_url;
         $form_state['values']['attributes']['data-editor-file-uuid'] = $file->uuid();
     }
     if (form_get_errors($form_state)) {
         unset($form['#prefix'], $form['#suffix']);
         $status_messages = array('#theme' => 'status_messages');
         $output = drupal_render($form);
         $output = '<div>' . drupal_render($status_messages) . $output . '</div>';
         $response->addCommand(new HtmlCommand('#editor-image-dialog-form', $output));
     } else {
         $response->addCommand(new EditorDialogSave($form_state['values']));
         $response->addCommand(new CloseModalDialogCommand());
     }
     return $response;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:29,代码来源:EditorImageDialog.php

示例12: checkUserNameEmailExists

 /**
  * Check if username and email exists in the drupal db.
  *
  * @param array $params
  *   Array of name and mail values.
  * @param array $errors
  *   Array of errors.
  * @param string $emailName
  *   Field label for the 'email'.
  */
 public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email')
 {
     $config = CRM_Core_Config::singleton();
     $dao = new CRM_Core_DAO();
     $name = $dao->escape(CRM_Utils_Array::value('name', $params));
     $email = $dao->escape(CRM_Utils_Array::value('mail', $params));
     _user_edit_validate(NULL, $params);
     $errors = form_get_errors();
     if ($errors) {
         if (!empty($errors['name'])) {
             $errors['cms_name'] = $errors['name'];
         }
         if (!empty($errors['mail'])) {
             $errors[$emailName] = $errors['mail'];
         }
         // also unset drupal messages to avoid twice display of errors
         unset($_SESSION['messages']);
     }
     // Do the name check manually.
     $nameError = user_validate_name($params['name']);
     if ($nameError) {
         $errors['cms_name'] = $nameError;
     }
     $sql = "\n      SELECT name, mail\n      FROM {users}\n      WHERE (LOWER(name) = LOWER('{$name}')) OR (LOWER(mail) = LOWER('{$email}'))\n    ";
     $result = db_query($sql);
     $row = db_fetch_array($result);
     if (!$row) {
         return;
     }
     $user = NULL;
     if (!empty($row)) {
         $dbName = CRM_Utils_Array::value('name', $row);
         $dbEmail = CRM_Utils_Array::value('mail', $row);
         if (strtolower($dbName) == strtolower($name)) {
             $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', array(1 => $name));
         }
         if (strtolower($dbEmail) == strtolower($email)) {
             if (empty($email)) {
                 $errors[$emailName] = ts('You cannot create an email account for a contact with no email', array(1 => $email));
             } else {
                 $errors[$emailName] = ts('This email %1 is already registered. Please select another email.', array(1 => $email));
             }
         }
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:55,代码来源:Drupal6.php

示例13: pressButton

 /**
  * Simulate action of pressing of an Add More button. This function processes
  * the form based on the specified inputs and updates the form with the new
  * values in the cache so that the form's submit button can work correctly.
  *
  * @param string $triggering_element_name
  *   Name of the Add More button or value of Op key.
  * @param array $options
  *   Options array. If key "ajax" is set to TRUE, then
  *   $triggering_element_name is assumed to be name of the Add More button
  *   otherwise it is taken to be the value of Op key.
  *
  * @return Response
  *   Response object.
  */
 public function pressButton($triggering_element_name = NULL, $options = array())
 {
     $options += array('ajax' => FALSE);
     $ajax = $options['ajax'];
     // Make sure that a button with provided name exists.
     if ($ajax && !is_null($triggering_element_name) && !$this->buttonExists($triggering_element_name)) {
         return new Response(FALSE, NULL, "Button {$triggering_element_name} does not exist.");
     }
     if (!$ajax) {
         // If this is not an AJAX request, then the supplied name is the value of
         // Op parameter.
         $response = $this->fillOpValues($triggering_element_name);
         if (!$response->getSuccess()) {
             return $response;
         }
     }
     $this->clearErrors();
     $this->makeUncheckedCheckboxesNull();
     $this->removeFileFieldWeights();
     $old_form_state_values = !empty($this->form_state['values']) ? $this->form_state['values'] : array();
     $this->form_state = form_state_defaults();
     $args = func_get_args();
     // Remove $triggering_element_name from the arguments.
     array_shift($args);
     // Remove $options from the arguments.
     array_shift($args);
     $this->form_state['build_info']['args'] = $args;
     $this->form_state['programmed_bypass_access_check'] = FALSE;
     //$this->form_state['values']['form_build_id'] = $this->form['#build_id'];
     // Add more field button sets $form_state['rebuild'] to TRUE because of
     // which submit handlers are not called. Hence we set it back to FALSE.
     $this->removeKey('input');
     $this->removeKey('triggering_element');
     $this->removeKey('validate_handlers');
     $this->removeKey('submit_handlers');
     $this->removeKey('clicked_button');
     $this->form_state['input'] = $old_form_state_values;
     $this->form_state['input']['form_build_id'] = $this->form['#build_id'];
     if (!is_null($triggering_element_name) && $ajax) {
         $this->form_state['input']['_triggering_element_name'] = $triggering_element_name;
     }
     $this->form_state['no_redirect'] = TRUE;
     $this->form_state['method'] = 'post';
     //$this->form_state['programmed'] = TRUE;
     $this->form = drupal_build_form($this->form_id, $this->form_state);
     if ($ajax && !is_null($triggering_element_name)) {
         unset($this->form_state['values'][$triggering_element_name]);
     }
     // Reset the static cache for validated forms otherwise form won't go
     // through validation function again.
     drupal_static_reset('drupal_validate_form');
     if ($errors = form_get_errors()) {
         $this->errors = $errors;
         return new Response(FALSE, NULL, implode(", ", $this->errors));
     }
     return new Response(TRUE, NULL, "");
 }
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:72,代码来源:Form.php

示例14: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, array &$form_state)
 {
     $form_state['view']->getExecutable()->displayHandlers->get($form_state['display_id'])->validateOptionsForm($form['options'], $form_state);
     if (form_get_errors($form_state)) {
         $form_state['rerender'] = TRUE;
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:Display.php

示例15: form_get_errors

<?php

$messages = form_get_errors();
if (!empty($messages)) {
    foreach ($messages as $message) {
        drupal_set_message($message, 'error');
    }
    print theme('status_messages');
}
print drupal_render_children($form);
开发者ID:GitError404,项目名称:favrskov.dk,代码行数:10,代码来源:user-login.tpl.php


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