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


PHP CModel::hasErrors方法代码示例

本文整理汇总了PHP中CModel::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP CModel::hasErrors方法的具体用法?PHP CModel::hasErrors怎么用?PHP CModel::hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CModel的用法示例。


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

示例1: beginControlGroup

 public function beginControlGroup(CModel $model, $attributes, $htmlOptions = array())
 {
     if (!isset($htmlOptions['class'])) {
         $htmlOptions['class'] = 'control-group';
     }
     if (!is_array($attributes)) {
         $attributes = explode(',', str_replace(' ', '', $attributes));
     }
     foreach ($attributes as $attr) {
         if ($model->hasErrors($attr)) {
             $htmlOptions['class'] .= ' error';
         }
     }
     return CHtml::tag('div', $htmlOptions, false, false);
 }
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:15,代码来源:AdminForm.php

示例2: validate

 /**
  * Validates the specified object.
  * @param CModel $object the data object being validated
  * @param array $attributes the list of attributes to be validated. Defaults to null,
  * meaning every attribute listed in {@link attributes} will be validated.
  */
 public function validate($object, $attributes = null)
 {
     if (is_array($attributes)) {
         $attributes = array_intersect($this->attributes, $attributes);
     } else {
         $attributes = $this->attributes;
     }
     foreach ($attributes as $attribute) {
         if (!$this->skipOnError || !$object->hasErrors($attribute)) {
             $this->validateAttribute($object, $attribute);
         }
     }
 }
开发者ID:motin,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:CValidator.php

示例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);
 }
开发者ID:juankie,项目名称:gestcb9git,代码行数:19,代码来源:TbHtml.php

示例4: horizontalFieldRow

 /**
  * Renders a horizontal custom field row for a model attribute.
  *
  * @param array|string $fieldData Pre-rendered field as string or array of arguments for call_user_func_array() function.
  * @param \CModel $model The data model.
  * @param string $attribute The attribute.
  * @param array $rowOptions Row options.
  */
 protected function horizontalFieldRow(&$fieldData, &$model, &$attribute, &$rowOptions)
 {
     $controlGroupHtmlOptions = ['class' => 'control-group'];
     if ($model->hasErrors($attribute)) {
         Html::addCssClass($controlGroupHtmlOptions, \CHtml::$errorCss);
     }
     echo \CHtml::openTag('div', $controlGroupHtmlOptions);
     Html::addCssClass($rowOptions['labelOptions'], 'control-label');
     if (isset($rowOptions['label'])) {
         if (!empty($rowOptions['label'])) {
             $for = isset($rowOptions['labelOptions']['for']) ? $rowOptions['labelOptions']['for'] : \CHtml::activeId($model, $attribute);
             echo \CHtml::label($rowOptions['label'], $for, $rowOptions['labelOptions']);
         }
     } else {
         echo $this->labelEx($model, $attribute, $rowOptions['labelOptions']);
     }
     echo '<div class="controls">';
     if (!empty($rowOptions['prepend']) || !empty($rowOptions['append'])) {
         $this->renderAddOnBegin($rowOptions['prepend'], $rowOptions['append'], $rowOptions['prependOptions']);
     }
     if (is_array($fieldData)) {
         echo call_user_func_array($fieldData[0], $fieldData[1]);
     } else {
         echo $fieldData;
     }
     if (!empty($rowOptions['prepend']) || !empty($rowOptions['append'])) {
         $this->renderAddOnEnd($rowOptions['append'], $rowOptions['appendOptions']);
     }
     if ($this->showErrors && $rowOptions['errorOptions'] !== false) {
         echo $this->error($model, $attribute, $rowOptions['errorOptions'], $rowOptions['enableAjaxValidation'], $rowOptions['enableClientValidation']);
     }
     if (isset($rowOptions['hint'])) {
         if (!isset($rowOptions['hintOptions']['class'])) {
             Html::addCssClass($rowOptions['hintOptions'], $this->hintCssClass);
         }
         echo \CHtml::tag($this->hintTag, $rowOptions['hintOptions'], $rowOptions['hint']);
     }
     echo '</div></div>';
     // controls, control-group
 }
开发者ID:intersvyaz,项目名称:yii-bootstrap,代码行数:48,代码来源:ActiveForm.php

示例5: verticalGroup

 /**
  * Renders a vertical custom field group for a model attribute.
  *
  * @param array|string $fieldData Pre-rendered field as string or array of arguments for call_user_func_array() function.
  * @param CModel $model The data model.
  * @param string $attribute The attribute.
  * @param array $options Row options.
  * 
  */
 protected function verticalGroup(&$fieldData, &$model, &$attribute, &$options)
 {
     $groupOptions = isset($options['groupOptions']) ? $options['groupOptions'] : array();
     self::addCssClass($groupOptions, 'form-group');
     if ($model->hasErrors($attribute)) {
         self::addCssClass($groupOptions, 'has-error');
     }
     echo CHtml::openTag('div', $groupOptions);
     self::addCssClass($options['labelOptions'], 'control-label');
     if (isset($options['label'])) {
         if (!empty($options['label'])) {
             echo CHtml::label($options['label'], CHtml::activeId($model, $attribute), $options['labelOptions']);
         }
     } else {
         echo $this->labelEx($model, $attribute, $options['labelOptions']);
     }
     if (!empty($options['prepend']) || !empty($options['append'])) {
         $this->renderAddOnBegin($options['prepend'], $options['append'], $options['prependOptions']);
     }
     if (is_array($fieldData)) {
         echo call_user_func_array($fieldData[0], $fieldData[1]);
     } else {
         echo $fieldData;
     }
     if (!empty($options['prepend']) || !empty($options['append'])) {
         $this->renderAddOnEnd($options['append'], $options['appendOptions']);
     }
     if ($this->showErrors && $options['errorOptions'] !== false) {
         echo $this->error($model, $attribute, $options['errorOptions'], $options['enableAjaxValidation'], $options['enableClientValidation']);
     }
     if (isset($options['hint'])) {
         self::addCssClass($options['hintOptions'], $this->hintCssClass);
         echo CHtml::tag($this->hintTag, $options['hintOptions'], $options['hint']);
     }
     echo '</div>';
 }
开发者ID:ardhimaarik,项目名称:dapus-generator,代码行数:45,代码来源:TbActiveForm.php

示例6: hasErrors

 /**
  * @return true/false. If the form and/or the model has any errors.
  * Currently this method does not support specifying the $attributeNameOrNames parameter.
  */
 public function hasErrors($attributeNameOrNames = null)
 {
     $hasFormErrors = parent::hasErrors($attributeNameOrNames);
     if ($hasFormErrors) {
         return true;
     }
     return false;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:12,代码来源:ModelForm.php

示例7: 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);
 }
开发者ID:codemix,项目名称:bs3activeform,代码行数:41,代码来源:BS3ActiveForm.php


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