예제 #1
0
 /**
  * Displays a summary of validation errors for one or several models.
  * @param mixed $models the models whose input errors are to be displayed.
  * @param string $header a piece of HTML code that appears in front of the errors
  * @param string $footer a piece of HTML code that appears at the end of the errors
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @return string the error summary. Empty if no errors are found.
  */
 public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())
 {
     if (!$this->enableAjaxValidation && !$this->enableClientValidation) {
         return BsHtml::errorSummary($models, $header, $footer, $htmlOptions);
     }
     BsArray::defaultValue('id', $this->id . '_es_', $htmlOptions);
     $html = BsHtml::errorSummary($models, $header, $footer, $htmlOptions);
     if ($html === '') {
         if ($header === null) {
             $header = '<p>' . Yii::t('yii', 'Please fix the following input errors:') . '</p>';
         }
         BsHtml::addCssClass(BsHtml::$errorSummaryCss, $htmlOptions);
         BsHtml::addCssStyle('display:none', $htmlOptions);
         $html = CHtml::tag('div', $htmlOptions, $header . '<ul><li>dummy</li></ul>' . $footer);
     }
     $this->summaryID = $htmlOptions['id'];
     foreach (is_array($models) ? $models : array($models) as $model) {
         foreach ($model->getSafeAttributeNames() as $attribute) {
             $this->_summaryAttributes[] = CHtml::activeId($model, $attribute);
         }
     }
     return $html;
 }