Ejemplo n.º 1
0
 /**
  * The new checkout views display errors in a specific way.
  *
  * We take the errors that the framework generates,
  * create an html string for sending to the view.
  *
  * @return string - html
  */
 protected function formatErrors()
 {
     $flashErrors = array();
     foreach (Yii::app()->user->getFlashes(false) as $key => $msg) {
         if (in_array($key, array('warning', 'error'))) {
             $flashErrors[$key] = Yii::app()->user->getFlash($key);
         }
     }
     $controllerErrors = $this->checkoutForm->getErrors() + $flashErrors;
     if (count($controllerErrors) === 0) {
         return null;
     }
     // $arrAllErrors is an array of array of errors.
     $strErrors = _xls_convert_errors_display(_xls_convert_errors(_xls_make2dimArray($controllerErrors)));
     if (str_replace("\n", "", $strErrors) === "") {
         return null;
     }
     // Format errors for html display.
     $strErrors = str_replace("\n", "<br>", $strErrors);
     // Remove first break from string.
     $strErrors = preg_replace("/<br>/", "", $strErrors, 1);
     return sprintf('<div class="form-error"><p>%s</p></div>', $strErrors);
 }