In my registration form, I have a checkbox where a user can accept to receive newsletters.
In create function I want to display all passed data:
protected function create(array $data)
{
dd($data);
}
The name of my checkbox field is newsletter. When I do dd(), I don't get the value for the newsletter, only for: name, email and password.
If I add this newsletter to Validator then it is shown.
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'newsletter' => 'required',
]);
}
Now, when I do dd() it is passed, but I don't want this checkbox to be required. It should be optional. Should I change something in Validator or?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zxlGNX
via IFTTT
Aucun commentaire:
Enregistrer un commentaire