Changing span content on error

I need to change a span content if an error happen’s how can I do that?

I have this on my view
<span class='error'>{$error.main}</span>

I want to populate that $error.main with the error and show it to user.

Hello,

You can append error message to the page by
SugarApplication::appendErrorMessage(‘You have been redirected here because …’);
This error message will be displayed on next page where you redirect it.
Here is the blog on redirect and message appending

@Fairydx
You can add to your page javascript:

echo "<script> ajaxStatus.flashStatus('Error #____!!!!!!',5000); </script>";

For example I change the file modules/Users/User.php:

...
if (isset($_SESSION['login_error'])) {
/* There is your message */
    echo "<script> ajaxStatus.flashStatus('Error #____!!!!!!',5000); </script>";
/* */
    $sugar_smarty->assign('LOGIN_ERROR', $_SESSION['login_error']);
}
if (isset($_SESSION['waiting_error'])) {
    $sugar_smarty->assign('WAITING_ERROR', $_SESSION['waiting_error']);
}
...

But you should change your style.scc because the block for message hide under menu now.

  1. Edit file: themes/SuiteP/css/suitep-base/editview.scss
    New code for #ajaxStatusDiv:
#ajaxStatusDiv{position:fixed;top:70px;background:#fff;color:#f08377;padding:5px;border:1px solid transparent;filter:alpha(opacity=80);z-index:20}
  1. Rebuild style.css