I have always used #flash(flashKey)# to display my...
# lucee
r
I have always used #flash(flashKey)# to display my error,info, etc messages. Above lucee 5.4 it breaks and says "Message Can't cast Complex Object Type Array to String Detail Use Built-In-Function "serialize(Array):String" to create a String from Array" . Anyone know how to rewrite it? if I was hardcoding it would be flash("info").
b
Dump out the variable to see what's in it
I assume it's an array of messages you need to loop over
z
Or .toJSON()
r
Perfect. It is an array of messages. Thanks
b
I don't think he wants to show JSON to his end users 🙂
z
Only suggested it as dump comes with a lot of HTML, etc and depending on the context it's being output, it's sometimes cleaner
Just for debugging
d
Sorry to hijack, but even with years of CFML development, #flash(flashKey)# is new to me. We've recently converted our servers to Lucee, is there value in understanding the flash scope (if it is a scope) and putting it to good use or if I've missed it at this point, do I just let it lie?
z
there isn't a flash bif????
b
Its just a function provided by his framework
z
consider all the flash stuff deprecated
✅ 1
b
Flash is a common name for short term storage across requests, often times put in the session scope
z
Flash was a common way to hack browsers more like it!
b
Coldbox had a flash memory feature. I want to say ROR popularized it.
No, not like macrromedia flash, lol
His flash data is likely success or error messages from the previous form submit "flashed" across to the next request where they are displayed.
👍 1
r
@David Johnson Yes what Brad said is correct. I was working on some cfwheels code and flash() is part of the framework for displaying messages. Cfwheels was originally spawned from ROR ideas. It just started throwing the error message after Lucee 5.4. I never paid attention to how flash works. I assumed it was just a struct with key/values so it threw me when I saw that message. For example, in the framework if I wanted to add a message after an update I could do the following:
Copy code
flashInsert(success="Your contact info was updated successfully");
Then on next page you could do flash("success") to display the message or flashmessages() to display all messages you've added.