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


PHP form_set_error函数代码示例

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


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

示例1: updateDatabase

 /**
  * Write the values into the database.
  * Return 0 if there was an error, else 1.
  */
 function updateDatabase($form, $myvalues)
 {
     //Try to create the record now
     $nSiteID = $this->m_oContext->getSiteID();
     $nIEN = $myvalues['tid'];
     $nUID = $this->m_oContext->getUID();
     $sCWFS = $this->m_oTT->getTicketWorkflowState($nSiteID . '-' . $nIEN);
     $updated_dt = date("Y-m-d H:i:s", time());
     if ($myvalues['reason'] == 'Other' && (!isset($myvalues['suspend_notes_tx']) || trim($myvalues['suspend_notes_tx']) == '')) {
         form_set_error('suspend_notes_tx', 'Cannot suspend a ticket without an explanation when reason is "Other".');
         return 0;
     }
     //Create the raptor_ticket_suspend_notes record now
     try {
         $oInsert = db_insert('raptor_ticket_suspend_notes')->fields(array('siteid' => $nSiteID, 'IEN' => $nIEN, 'notes_tx' => 'REASON:' . $myvalues['reason'] . '<br>NOTES:' . $myvalues['suspend_notes_tx'], 'author_uid' => $nUID, 'created_dt' => $updated_dt))->execute();
     } catch (\Exception $e) {
         error_log('Failed to create raptor_ticket_suspend_notes: ' . $e . "\nDetails..." . print_r($oInsert, true));
         form_set_error('suspend_notes_tx', 'Failed to save notes for this ticket!');
         return 0;
     }
     $sNewWFS = 'IA';
     $this->m_oTT->setTicketWorkflowState($nSiteID . '-' . $nIEN, $nUID, $sNewWFS, $sCWFS, $updated_dt);
     //Write success message
     drupal_set_message('Suspended ' . $myvalues['tid'] . ' (' . $myvalues['procName'] . ')');
     return 1;
 }
开发者ID:rmurray1,项目名称:RAPTOR,代码行数:30,代码来源:SuspendTicketPage.php

示例2: CALLBACK_commerce_extra_configure_validate

/**
 * CALLBACK_commerce_extra_configure_validate()
 */
function CALLBACK_commerce_extra_configure_validate(&$form, &$form_state)
{
    // Example from commerce_extra_quantity feature
    if (!is_numeric($form_state['values']['commerce_extra_quantity_cardinality'])) {
        form_set_error('commerce_extra_quantity_cardinality', t('Field @field_name must be numeric value.', array('@field_name' => t('Quantity cardinality'))));
    }
}
开发者ID:vorvor,项目名称:diszkont,代码行数:10,代码来源:commerce_extra.api.php

示例3: hookAdminSettingsValidate

 /**
  * Validation for the administrative settings form.
  *
  * @param object $form
  *   An associative array containing the structure of the form.
  * @param object $form_state
  *   A keyed array containing the current state of the form.
  */
 public static function hookAdminSettingsValidate($form, &$form_state)
 {
     if ($form_state['values']['node_expire_date_entry_elements'] == 1 && $form_state['values']['node_expire_handle_content_expiry'] != 0 && !module_exists('date_popup')) {
         form_set_error('date_entry_elements', t('To use "Date popups" option Date module should be installed with Date Popup enabled.') . ' ' . t('This option is not available in legacy mode.'));
     }
     // End of node_expire_admin_settings_validate().
 }
开发者ID:kastowo,项目名称:idbigdata,代码行数:15,代码来源:AdminHookHandler.php

示例4: deleteUserPage_validate

function deleteUserPage_validate($form, $form_state)
{
    if ($form_state['values']['acknowledgement'] == 0) {
        // ensuring that the user has checked the checkbox
        form_set_error('checkbox', 'You must acknowledge that you are intentionally deleting your account');
    }
}
开发者ID:ChapResearch,项目名称:CROMA,代码行数:7,代码来源:deleteUser.php

示例5: validateConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateConfigurationForm($form, $form_state);
     if (empty($form_state['values']['width']) && empty($form_state['values']['height'])) {
         form_set_error('data', $form_state, $this->t('Width and height can not both be blank.'));
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:ScaleImageEffect.php

示例6: hook_comment_validate

/**
 *  The user has just finished editing the comment and is trying to
 *  preview or submit it. This hook can be used to check or
 *  even modify the node. Errors should be set with form_set_error().
 *
 * @param $form_values
 *   Passes in an array of form values submitted by the user.
 * @return
 *   Nothing.
 */
function hook_comment_validate(&$form_values)
{
    // if the subject is the same as the comment.
    if ($form_values['subject'] == $form_values['comment']) {
        form_set_error('comment', t('you should write more text than in the subject'));
    }
}
开发者ID:schuyler1d,项目名称:drupal,代码行数:17,代码来源:comment.api.php

示例7: validatePreviewForm

 /**
  * Implements WidgetInterface::validatePreviewForm().
  *
  * Right now no validation is necessary.
  */
 public function validatePreviewForm($form, &$form_state)
 {
     $date = self::getTimeStamp($form_state);
     if (!$date) {
         form_set_error('preview_date_wrapper', t('Invalid Date/Time given.'));
     }
 }
开发者ID:stevebresnick,项目名称:iomedia_stp_d7_core,代码行数:12,代码来源:DateWidget.php

示例8: validateName

 /**
  * Form element validation handler for 'name' in form_test_validate_form().
  */
 public function validateName(&$element, FormStateInterface $form_state)
 {
     $triggered = FALSE;
     if ($form_state['values']['name'] == 'element_validate') {
         // Alter the form element.
         $element['#value'] = '#value changed by #element_validate';
         // Alter the submitted value in $form_state.
         form_set_value($element, 'value changed by form_set_value() in #element_validate', $form_state);
         $triggered = TRUE;
     }
     if ($form_state['values']['name'] == 'element_validate_access') {
         $form_state['storage']['form_test_name'] = $form_state['values']['name'];
         // Alter the form element.
         $element['#access'] = FALSE;
         $triggered = TRUE;
     } elseif (!empty($form_state['storage']['form_test_name'])) {
         // To simplify this test, just take over the element's value into $form_state.
         form_set_value($element, $form_state['storage']['form_test_name'], $form_state);
         $triggered = TRUE;
     }
     if ($triggered) {
         // Output the element's value from $form_state.
         drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state['values']['name'])));
         // Trigger a form validation error to see our changes.
         form_set_error('', $form_state);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:Callbacks.php

示例9: validate

 public function validate($form, &$form_state)
 {
     $remote = Remote::load($form_state['values']['remote']);
     if (!$remote) {
         form_set_error('remote', 'The specified remote is invalid. Please choose another.');
     }
 }
开发者ID:sammarks,项目名称:publisher,代码行数:7,代码来源:SyncMenuLinksForm.php

示例10: simplemap_exclusions_form_validate

function simplemap_exclusions_form_validate($form, &$form_state)
{
    $input = $form_state['input'];
    if (!is_numeric($input['nid'])) {
        form_set_error('nid', t('The NID must be a number'));
    }
}
开发者ID:Samuel-Moncarey,项目名称:custom_sitemap,代码行数:7,代码来源:exclusions_form.php

示例11: flux_theme_settings_validate

/**
 * Validate handler where we actually save the files...
 */
function flux_theme_settings_validate($form, &$form_state)
{
    // Handle file uploads.
    $validators = array('file_validate_is_image' => array());
    // Check for a new uploaded logo.
    $file = file_save_upload('cover_photo_upload', $validators);
    if (isset($file)) {
        // File upload was attempted.
        if ($file) {
            // Put the temporary file in form_values so we can save it on submit.
            $form_state['values']['cover_photo_upload'] = $file;
        } else {
            // File upload failed.
            form_set_error('cover_photo_upload', t('The image could not be uploaded.'));
        }
    }
    $validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
    // If the user provided a path for a logo or favicon file, make sure a file
    // exists at that path.
    if ($form_state['values']['cover_photo_path']) {
        $path = flux_system_theme_settings_validate_path($form_state['values']['cover_photo_path']);
        if (!$path) {
            form_set_error('cover_photo_path', t('The custom path is invalid.'));
        }
    }
}
开发者ID:sheldonrampton,项目名称:pushtape-drops,代码行数:29,代码来源:theme-settings.php

示例12: validateForm

 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, array &$form_state)
 {
     parent::validateForm($form, $form_state);
     if (!intval($form_state['values']['request_token_lifetime'], 10)) {
         form_set_error('oauth_request_token_lifetime', t('The request token lifetime must be a non-zero integer value.'));
     }
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:10,代码来源:OAuthSettingsForm.php

示例13: looksValid

 /**
  * Some checks to validate the data before we try to save it.
  */
 function looksValid($form, $myvalues)
 {
     $is_good = TRUE;
     //Array ( [table_container] => Array ( [orders] => Array ( [449] => 449 [601] => 601
     $orders = $myvalues['table_container']['orders'];
     if (!is_array($orders)) {
         form_set_error('table_container', 'Did not find any orders!');
         $is_good = FALSE;
     } else {
         $foundone = FALSE;
         foreach ($orders as $key => $value) {
             if ($key == $value) {
                 $foundone = TRUE;
                 break;
             }
         }
         if (!$foundone) {
             form_set_error('table_container', 'Did not find any selected orders');
             $is_good = FALSE;
         }
     }
     if (!isset($myvalues['cancelreason']) || !is_numeric($myvalues['cancelreason'])) {
         form_set_error('cancelreason', 'Did not find any a valid cancel reason');
         $is_good = FALSE;
     }
     return $is_good;
 }
开发者ID:rmurray1,项目名称:RAPTOR,代码行数:30,代码来源:CancelOrdersPage.php

示例14: updateDatabase

 /**
  * Write the values into the database.
  * Return 1 if all okay, else return 0.
  */
 function updateDatabase($myvalues)
 {
     if (!isset($myvalues['raw_list_rows'])) {
         die("Cannot update user record because missing raw_list_rows in array!\n" . var_dump($myvalues));
     }
     $tablename = $this->m_sTablename;
     $aFieldNames = $this->m_aFieldNames;
     $aOrderBy = $this->m_aOrderBy;
     $aRequiredCols = $this->m_aRequiredCols;
     $aMaxLenCols = $this->m_aMaxLenCols;
     $aDataTypeCols = $this->m_aDataTypeCols;
     $aRawRows = $this->m_oPageHelper->parseRawText($myvalues['raw_list_rows']);
     $result = $this->m_oPageHelper->parseRows($aRawRows, $aRequiredCols, $aMaxLenCols, $aDataTypeCols);
     $errors = $result['errors'];
     if (count($errors) > 0) {
         if (count($errors) > 1) {
             form_set_error("raw_list_rows", '<ol><li>' . implode('<li>', $errors) . '</ol>');
         } else {
             form_set_error("raw_list_rows", $errors[0]);
         }
         /*
                     foreach($errors as $error)
                     {
            form_set_error("raw_list_rows",$error);
                     }
         * 
         */
         return 0;
     } else {
         $nRows = $this->m_oPageHelper->writeValues($tablename, $aFieldNames, $result['parsedrows']);
         return 1;
     }
 }
开发者ID:rmurray1,项目名称:RAPTOR,代码行数:37,代码来源:EditListHydrationPage.php

示例15: looksValid

 /**
  * Some checks to validate the data before we try to save it.
  * @param type $form
  * @param type $myvalues
  * @return TRUE or FALSE
  */
 function looksValid($form, $myvalues)
 {
     $bGood = TRUE;
     if (!isset($myvalues['reason']) || !is_numeric($myvalues['reason'])) {
         form_set_error('reason', 'Did not find any a valid cancel reason');
         $is_good = FALSE;
     }
     return $bGood;
 }
开发者ID:rmurray1,项目名称:RAPTOR,代码行数:15,代码来源:CancelOrderPage.php


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