本文整理汇总了PHP中CModel::getError方法的典型用法代码示例。如果您正苦于以下问题:PHP CModel::getError方法的具体用法?PHP CModel::getError怎么用?PHP CModel::getError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::getError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fieldClass
/**
* Returns input container class for any given attribute, depending on validation conditions.
* @param CModel $model the data model
* @param string $attribute the attribute name
*/
public function fieldClass($model, $attribute)
{
$class = 'control-group';
if ($model->getError($attribute)) {
$class .= ' error';
}
return $class;
}
示例2: errorModelSummery
/**
* get error info from model
*
* @param CModel $model
* @return string
* @see CModel
*/
public static function errorModelSummery($model, $attribute = null)
{
if (is_null($attribute)) {
return self::errorSummery($model->getErrors());
} else {
$aryError = $model->getError($attribute, false);
return empty($aryError) ? '' : self::errorSummery(array($aryError));
}
}
示例3: customActiveControlGroup
/**
* Generates a custom (pre-rendered) active form control group.
* @param string $input the rendered input.
* @param CModel $model the data model.
* @param string $attribute the attribute.
* @param array $htmlOptions additional HTML attributes.
* @return string the generated control group.
*/
public static function customActiveControlGroup($input, $model, $attribute, $htmlOptions = array())
{
// modificado segun lo visto en el foro de yii
$htmlOptions['input'] = $input;
if ($model->hasErrors($attribute)) {
$htmlOptions['color'] = TbHtml::INPUT_COLOR_ERROR;
$htmlOptions['help'] = $model->getError($attribute);
$htmlOptions['helpOptions'] = array('type' => TbHtml::HELP_TYPE_BLOCK);
}
return self::activeControlGroup(self::INPUT_TYPE_CUSTOM, $model, $attribute, $htmlOptions);
}
示例4: error
/**
* Displays the first validation error for a model attribute.
* @param CModel $model the data model
* @param string $attribute the attribute name
* @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
* This parameter has been available since version 1.0.7.
* @return string the error display. Empty if no errors are found.
* @see CModel::getErrors
* @see errorMessageCss
*/
public static function error($model, $attribute, $htmlOptions = array())
{
$error = $model->getError($attribute);
if ($error != '') {
if (!isset($htmlOptions['class'])) {
$htmlOptions['class'] = self::$errorMessageCss;
}
return self::tag('div', $htmlOptions, $error);
} else {
return '';
}
}
示例5: beginControlGroup
/**
* Begins a form group.
*
* Into the form group belongs the label, the input and the error.
*
* @param CModel $model The model
* @param string $attribute The attribute
*
* @access public
* @return string
*/
public function beginControlGroup($model, $attribute, $options = array())
{
$option = array();
$option['class'] = 'form-group';
$error = $model->getError($attribute);
if (!empty($error)) {
EBootstrap::mergeClass($option, array('has-error'));
}
EBootstrap::mergeClass($options, $option);
return EBootstrap::openTag('div', $options);
}
示例6: renderGroup
/**
* @param string $method the CActiveForm method name, e.g. textField, dropDownList, etc.
* @param CModel $model the form model
* @param string $attribute the attribute name
* @param bool|array $listOptions list options or false if none
* @param array $options group options
* @return string the rendered form group
*/
protected function renderGroup($method, $model, $attribute, $listOptions, $options)
{
if (isset($options['label']) && $options['label'] === false) {
$beginLabel = $endLabel = $labelTitle = $label = '';
} else {
$beginLabel = \CHtml::openTag('label', $options['labelOptions']);
$endLabel = \CHtml::closeTag('label');
$labelTitle = isset($options['label']) ? $options['label'] : $model->getAttributeLabel($attribute);
$label = \CHtml::tag('label', $options['labelOptions'], $labelTitle);
}
$beginWrapper = \CHtml::openTag($options['wrapperTag'], $options['wrapperOptions']);
$endWrapper = \CHtml::closeTag($options['wrapperTag']);
if ($model->hasErrors($attribute) && $options['enableErrorBlock']) {
$error = \CHtml::tag($options['errorTag'], $options['errorOptions'], $model->getError($attribute));
$options['groupOptions']['class'] = isset($options['groupOptions']['class']) ? $options['groupOptions']['class'] . ' has-error' : 'has-error';
} else {
$error = '';
}
$help = isset($options['helpText']) ? \CHtml::tag($options['helpTag'], $options['helpOptions'], $options['helpText']) : '';
if ($this->layout === 'inline' && !isset($options['inputOptions']['placeholder'])) {
$options['inputOptions']['placeholder'] = $labelTitle;
}
if ($listOptions) {
$input = parent::$method($model, $attribute, $listOptions, $options['inputOptions']);
} else {
$input = parent::$method($model, $attribute, $options['inputOptions']);
}
if (isset($options['inputTemplate'])) {
$input = strtr($options['inputTemplate'], array('{input}' => $input));
}
$content = strtr($options['template'], array('{label}' => $label, '{beginLabel}' => $beginLabel, '{labelTitle}' => $labelTitle, '{endLabel}' => $endLabel, '{beginWrapper}' => $beginWrapper, '{endWrapper}' => $endWrapper, '{input}' => $input, '{error}' => $error, '{help}' => $help));
return \CHtml::tag($options['groupTag'], $options['groupOptions'], $content);
}