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

Too many messages #5

Closed
cugrif opened this issue Jul 30, 2019 · 5 comments
Closed

Too many messages #5

cugrif opened this issue Jul 30, 2019 · 5 comments

Comments

@cugrif
Copy link

cugrif commented Jul 30, 2019

Hi
Thanks for your extension.

I have some trouble.

Example

<input type="text" name="post_name[de]">
<input type="text" name="post_name[en]">
class MyRequest extends FormRequest{
  public function rules(): array
    {
        return [
            'post_name.*' => [
                UniqueTranslationRule::for('posts', 'name')
            ]
        ];
}}

When i put exists values and submit form, i got a lot of messages:
screenshot

Is there any way to generate only one message for each language?

Best regards

@ivanvermeyen
Copy link
Contributor

Hi,

I see your point :)
This behavior was actually a request some time ago (#1).
But there may well be a decent solution to handle both use cases.
I'll have to dig back in and think about how to do this though.

@Xinecraft
Copy link

If we use something like https://formvuelar.netlify.com/ this bug will get annoying and hard to fix I think from the frontend side.

@ivanvermeyen
Copy link
Contributor

Hello,

I agree that always returning both single and array error messages is not optimal after all and it's also not how Laravel handles form errors by default.

I will revert back to only returning relevant messages and try to work out some option to change the behavior for use cases as described in #1 by @ctf0) .

This will need to be a new major version, since it might have an impact on existing implementations.

@ivanvermeyen
Copy link
Contributor

ivanvermeyen commented Jan 21, 2020

I pushed an update to dev-master that uses Laravel's default behavior.
Only one error will be returned per form attribute:

Form Field Validation Rule Error Key
slug 'slug' => 'unique_translation:table,column' slug
slug[en] 'slug.*' => 'unique_translation:table,column' slug.en

If you could try or review it, I will tag a new release and then see if I can add some options for extra error messages... 👌

@ivanvermeyen
Copy link
Contributor

Tagged in 3.0.0 👍

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

3 participants