本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}