當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTML_QuickForm::errorMessage方法代碼示例

本文整理匯總了PHP中HTML_QuickForm::errorMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTML_QuickForm::errorMessage方法的具體用法?PHP HTML_QuickForm::errorMessage怎麽用?PHP HTML_QuickForm::errorMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTML_QuickForm的用法示例。


在下文中一共展示了HTML_QuickForm::errorMessage方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

 /**
  * Simple easy to use wrapper around addElement. Deal with
  * simple validation rules
  *
  * @param string $type
  * @param string $name
  * @param string $label
  * @param string|array $attributes (options for select elements)
  * @param bool $required
  * @param array $extra
  *   (attributes for select elements).
  *
  * @return HTML_QuickForm_Element could be an error object
  */
 public function &add($type, $name, $label = '', $attributes = '', $required = FALSE, $extra = NULL)
 {
     if ($type == 'wysiwyg') {
         $attributes = ($attributes ? $attributes : array()) + array('class' => '');
         $attributes['class'] .= ' crm-form-wysiwyg';
         $type = "textarea";
     }
     if ($type == 'select' && is_array($extra)) {
         // Normalize this property
         if (!empty($extra['multiple'])) {
             $extra['multiple'] = 'multiple';
         } else {
             unset($extra['multiple']);
         }
         // Add placeholder option for select
         if (isset($extra['placeholder'])) {
             if ($extra['placeholder'] === TRUE) {
                 $extra['placeholder'] = $required ? ts('- select -') : ts('- none -');
             }
             if (($extra['placeholder'] || $extra['placeholder'] === '') && empty($extra['multiple']) && is_array($attributes) && !isset($attributes[''])) {
                 $attributes = array('' => $extra['placeholder']) + $attributes;
             }
         }
     }
     $element = $this->addElement($type, $name, $label, $attributes, $extra);
     if (HTML_QuickForm::isError($element)) {
         CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
     }
     if ($required) {
         if ($type == 'file') {
             $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'uploadedfile');
         } else {
             $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'required');
         }
         if (HTML_QuickForm::isError($error)) {
             CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
         }
     }
     return $element;
 }
開發者ID:hoegrammer,項目名稱:civicrm-core,代碼行數:54,代碼來源:Form.php

示例2: HTML_QuickForm_Error

 /**
  * Creates a quickform error object, extending the PEAR_Error class
  *
  * @param int   $code the error code
  * @param int   $mode the reaction to the error, either return, die or trigger/callback
  * @param int   $level intensity of the error (PHP error code)
  * @param mixed $debuginfo any information that can inform user as to nature of the error
  */
 function HTML_QuickForm_Error($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)
 {
     if (is_int($code)) {
         $this->PEAR_Error(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo);
     } else {
         $this->PEAR_Error("Invalid error code: {$code}", QUICKFORM_ERROR, $mode, $level, $debuginfo);
     }
 }
開發者ID:ksecor,項目名稱:civicrm,代碼行數:16,代碼來源:QuickForm.php

示例3: __construct

 /**
  * Creates a quickform error object, extending the PEAR_Error class
  *
  * @param int   $code the error code
  * @param int   $mode the reaction to the error, either return, die or trigger/callback
  * @param int   $level intensity of the error (PHP error code)
  * @param mixed $debuginfo any information that can inform user as to nature of the error
  */
 public function __construct($code = QUICKFORM_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)
 {
     if (is_int($code)) {
         parent::__construct(HTML_QuickForm::errorMessage($code), $code, $mode, $level, $debuginfo);
     } else {
         parent::__construct("Invalid error code: {$code}", QUICKFORM_ERROR, $mode, $level, $debuginfo);
     }
 }
開發者ID:elie89,項目名稱:moodle,代碼行數:16,代碼來源:QuickForm.php

示例4: array

 /**
  * Simple easy to use wrapper around addElement.
  *
  * Deal with simple validation rules.
  *
  * @param string $type
  * @param string $name
  * @param string $label
  * @param string|array $attributes (options for select elements)
  * @param bool $required
  * @param array $extra
  *   (attributes for select elements).
  *
  * @return HTML_QuickForm_Element
  *   Could be an error object
  */
 public function &add($type, $name, $label = '', $attributes = '', $required = FALSE, $extra = NULL)
 {
     // Fudge some extra types that quickform doesn't support
     if ($type == 'wysiwyg' || in_array($type, self::$html5Types)) {
         $attributes = ($attributes ? $attributes : array()) + array('class' => '');
         $attributes['class'] = ltrim($attributes['class'] . " crm-form-{$type}");
         $type = $type == 'wysiwyg' ? 'textarea' : 'text';
     }
     // @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
     if ($type == 'datepicker') {
         $attributes = $attributes ? $attributes : array();
         $attributes['data-crm-datepicker'] = json_encode((array) $extra);
         $type = "text";
     }
     if ($type == 'select' && is_array($extra)) {
         // Normalize this property
         if (!empty($extra['multiple'])) {
             $extra['multiple'] = 'multiple';
         } else {
             unset($extra['multiple']);
         }
         unset($extra['size'], $extra['maxlength']);
         // Add placeholder option for select
         if (isset($extra['placeholder'])) {
             if ($extra['placeholder'] === TRUE) {
                 $extra['placeholder'] = $required ? ts('- select -') : ts('- none -');
             }
             if (($extra['placeholder'] || $extra['placeholder'] === '') && empty($extra['multiple']) && is_array($attributes) && !isset($attributes[''])) {
                 $attributes = array('' => $extra['placeholder']) + $attributes;
             }
         }
     }
     $element = $this->addElement($type, $name, $label, $attributes, $extra);
     if (HTML_QuickForm::isError($element)) {
         CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
     }
     if ($required) {
         if ($type == 'file') {
             $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'uploadedfile');
         } else {
             $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'required');
         }
         if (HTML_QuickForm::isError($error)) {
             CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
         }
     }
     return $element;
 }
開發者ID:saurabhbatra96,項目名稱:civicrm-core,代碼行數:64,代碼來源:Form.php

示例5: ts

 /**
  * Simple easy to use wrapper around addElement. Deal with
  * simple validation rules
  *
  * @param string type of html element to be added
  * @param string name of the html element
  * @param string display label for the html element
  * @param string attributes used for this element.
  *               These are not default values
  * @param bool   is this a required field
  *
  * @return object    html element, could be an error object
  * @access public
  *
  */
 function &add($type, $name, $label = '', $attributes = '', $required = false, $javascript = null)
 {
     $element =& $this->addElement($type, $name, $label, $attributes, $javascript);
     if (HTML_QuickForm::isError($element)) {
         CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
     }
     if ($required) {
         $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'required');
         if (HTML_QuickForm::isError($error)) {
             CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
         }
     }
     return $element;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:29,代碼來源:Form.php


注:本文中的HTML_QuickForm::errorMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。