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

validated() method on form requests not working as expected with array fields #21186

Closed
royduin opened this issue Sep 14, 2017 · 1 comment
Closed

Comments

@royduin
Copy link

@royduin royduin commented Sep 14, 2017

  • Laravel Version: 5.5.2
  • PHP Version: 7.1.6
  • Database Driver & Version: MySQL 5.7.18

Description:

The new validated() method on form requests ($request->validated()) in Laravel 5.5 is pretty nice but does not work as expected with array fields. I'm getting this:

array:2 [▼
  "name" => array:2 [▼
    "*" => array:2 [▼
      0 => "Test"
      1 => "Test 2"
    ]
    "nl" => "Test"
  ]
  "content" => array:1 [▼
    "nl" => "Test"
  ]
]

Instead of

array:4 [▼
  "name" => array:2 [▼
    "nl" => "Test"
    "en" => "Test 2"
  ]
  "content" => array:2 [▼
    "nl" => "Test"
  ]
]

With this:

public function rules()
{
    return [
        'name.*'                        => '',
        'name.'.config('app.locale')    => 'required',
        'content.'.config('app.locale') => 'required',
    ];
}

By design or a bug?

@themsaid
Copy link
Member

@themsaid themsaid commented Sep 14, 2017

Please upgrade to 5.5.4

@themsaid themsaid closed this Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants