New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flashing arrays #7
Comments
Flashing should not be used for this becase flashing is for short info messages. Use $_SESSION or a wrapper.
|
@adear11 What is it you are trying to achieve? Not sure why you would add all |
If you submit a form, it is nice to flash that info in case of a validation failure, and you can re-render the data when the page is redirected. |
I'm reviving this, I will like to also insert an array as a message. $notificationMessage = [];
$notificationMessage[] = [
'type' => 'error',
'text' => 'This is an error'
];
$notificationMessage[] = [
'type' => 'warning',
'text' => 'This is a warning'
]; And be able to do this on my views: {{% if messages %}}
{{% for message in messages %}}
<div class="{{ message.type }}">{{ message.text }}</div>
{{% endfor %}}
{% endif %} What do you folks think? |
@wellingguzman, can you confirm if my pull request #8 is related to what you want to achieve? |
@NigelGreenway no, what I want exactly is to be able to add an array to |
@wellingguzman I am hoping to start on this tomorrow/Tuesday as a slim view plugin/extension. I can add a method of |
As per the comment by @geggleto, it would be best decoupled from this package but not had chance to do it until about now. |
@wellingguzman send a PR to remove |
@silentworks Would it not be best to just add an extra method of cc/ @wellingguzman |
@NigelGreenway I don't think that would help in @wellingguzman case. He actually wants the message itself to be anything he feels like, so it can be a It would also be useful to have a |
👍 for both an addMessages and the removal of the string typehint |
Allows an object, string or an array to be assigned to the storage array. refs: slimphp#7
I think this is now resolved. |
I have a situation where I'd like to be able to flash the POST data from the previous request. As I see it, the only way to do this right now would be to loop through the POST data and add each value as a separate key.
I'd really like to be able to, instead, simply pass in the parsed body of the request as an array and have all the array stored under one key.
So, instead of having to do something like:
I feel like it much better to be able to do this:
It seems to me that this would be an easy, and non-breaking change. Unless I'm mistaken, something as simple as changing the Messages::addMessage method like this should do it:
Another option would be to add a separate method for adding the request body as a message, but I don't know if that would be necessary.
Is this doable? I'd be happy to submit a pull request for it, but before I do I'm curious to know if this is acceptable, and if there are any reasons that this couldn't be done. I'd think that this would be a pretty common requirement so having a straightforward and quick way to do this would be great.
Thanks,
-A
The text was updated successfully, but these errors were encountered: