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

[New Feature Request] Add ability to set attributes on the flash divs

The front end framework I use (Foundation 6.3) has some things I can use on divs to make the closeable, but the div requires a specific attribute (data-closeable) to be set on it for this to work. I've worked around this in javascript on page load, but it would be nice to be able to set attributes on a flash container, in addition to the classes that we can already set.



43.9k
edited Feb '17

Hi,

NFR should be posted on github

You can give a try to add it by yourself, it should be somewhere here: https://github.com/phalcon/cphalcon/blob/master/phalcon/flash.zep#L221



7.5k

Lemme see if I can build out a pull request to go with the feature request...



7.5k

Unfortunately, it looks like adding this functionality would break existing functionality with how flashing messages works right now. The following is from phalcon/flash.zep, starting with line 224.

    public function outputMessage(string type, var message)
    {
        boolean automaticHtml, implicitFlush;
        var content, cssClasses, classes, typeClasses, eol, msg,
            htmlMessage, htmlAttributes, autoEscape, escaper, preparedMsg;

        let automaticHtml = (bool) this->_automaticHtml,
            autoEscape = (bool) this->_autoescape;

        if automaticHtml === true {
            let classes = this->_cssClasses;
            if fetch typeClasses, classes[type] {
                if typeof typeClasses == "array" {
                    let cssClasses = " class=\"" . join(" ", typeClasses) . "\"";
                } else {
                    let cssClasses = " class=\"" . typeClasses . "\"";
                }
            } else {
                let cssClasses = "";
            }

            let eol = PHP_EOL;
        }
        ...
    }

The way I envision this working was to set an array for each level, the first element being classes, the second being an attribute string. Since this indicates that the classes can be an array, I can only assume this has been addressed by someone else in the past, and needed the classes attached to levels to be able to defined by an array instead of a string.

I'd want some input from one of the core devs to see if a change around this would be worth persuing.

Hi,

NFR should be posted on github

You can give a try to add it by yourself, it should be somewhere here: https://github.com/phalcon/cphalcon/blob/master/phalcon/flash.zep#L221