# Alert Messages

![](https://user-images.githubusercontent.com/37282871/197667430-bba5bdb8-00ab-4b97-a219-7f2b7ba4fa51.png)

### Using alert\_msg($status);

Create a `with_msg(["message" => ""])`. Alert types example `[ default, primary, success, warning, danger ]` to give colors to the message to be shown.

After you set a `with_msg()` you can now show it to the views using the `alert_msg()` helper function. This helper function will display as alert and `unset/removes` the alert when refreshing the page.

#### How to display to views?

Just echo the `alert_msg()` helper function in your views like this.

* `Note:` that the default color of the alert message is `info`

```php
<?= alert_msg('danger') ?>
```

### Using Error::any();

You can display errors using the loop to customized the looks of the alerts. `Error:any()` contains all the message produce by the applciation.

```html
<?php if (!empty(Error::any())) { ?>
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <?= implode("<br>", Error::any()) ?>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
<?php } ?>
```

when using this method, make sure the alert message is dismissable everytime you refresh the page. To do that we need to add a `clear()` method above the footer include at the bottom of our file.

```html
  </div>
    </div>
</div>
<?php Error::clear() ?>
<?php require __DIR__ . '/../layouts/footer.php'; ?>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sprnva.gitbook.io/sprnva-docs/alert-messages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
