Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Divide message key further #10

Open
mano87 opened this issue Aug 17, 2018 · 2 comments
Open

Divide message key further #10

mano87 opened this issue Aug 17, 2018 · 2 comments

Comments

@mano87
Copy link

mano87 commented Aug 17, 2018

Currently, the key of the message is probably mainly used for the corresponding category "warning, info, danger, success". However, if you now have two forms in the page, the evaluation of this information and the output is a bit tricky. It would be nice if you can add the corresponding form name in addition to the key.

currently:

$flashMessages->flash('danger', 'You need to supply your email address');

suggestion:

$flashMessages->flash('danger', 'You need to supply your email address', 'form-name'); // OR
$flashMessages->flash('form-name:danger', 'You need to supply your email address');

$flashMessages->getFlashByForm('form-name');

What do you all mean?

@geerteltink
Copy link
Member

I have been thinking about this as well and currently use it something like $flashMessages->flash('form-name:danger', 'message');.

$flashMessages->getFlashByForm('form-name');

I wouldn't call it getFlashByForm. I rather would like to see something like getFlashByNamespace. It does the same but it's more general.

$flashMessages->flash('danger', 'You need to supply your email address', 'form-name');

This cannot happen without a BC break. The current signature is public function flash(string $key, $value, int $hops = 1) : void;. So you would have something like public function flash(string $key, $value, int $hops = 1, string $namespace = null) : void;.

However I think I rather see something like this:
public function flash(string $namespace, $value, int $hops = 1, array options = null) : void;,
where options can be anything. You can add your message level (error, danger, success), form name, field name or whatever you want. To make it even more powerful, a namespace could have multiple messages.

public function getMessagesForNamespace(string $namespace) : array;

@weierophinney
Copy link
Member

This repository has been closed and moved to mezzio/mezzio-flash; a new issue has been opened at mezzio/mezzio-flash#1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants