We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

flash returns a full html document to the client

The following line is in one of my controlle's actions:

    $this->flash->error("Error: Could not log in with provided credentials.");

According to the Phalcon Documentation, the code snippet above should output the following:

    <div class="errorMessage">Error:  Could not log in with provided credentials.</div>

Instead, it's outputting the following:

            <title>Site Title</title>
                <!-- js and css files referenced here -->
            <div class="errorMessage">Error: Could not log in with provided credentials.</div>
            <br/><br/>This is a footer  

The HTML above is returned as the "data" parameter in my "success" callback function in javascript

    function successCallback(data, textStatus, jqXHR){

The elements surrounding the actual "flash" element in the output are part of the index.phtml page I have just inside the "views" folder.

Are there any flags I have to set to ensure that only the desired "error" message div is returned instead of a full html document?


You have to disable unnecessary hierarchical view levels:



if you want to render just the action view (withouty layout)



So, both the answers above solve the problem, but I will give the accept answer tick to Phalcon because it came first. It is obvious that the setting of the "LEVEL_ACTION_VIEW" is explained in the "view" documentation for Phalcon, but I could not find any such references in the "FLASH" documentation.