Skip to content
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

Divide message key further #1

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

Divide message key further #1

weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Contributor

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?


Originally posted by @mano87 at zendframework/zend-expressive-flash#10

@weierophinney
Copy link
Contributor Author

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;


Originally posted by @geerteltink at zendframework/zend-expressive-flash#10 (comment)

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

No branches or pull requests

1 participant