php - laravel 5.2 set attribute name -
how set custom attributte names in laravel 5.2 try code, doesn't work:
$attnames = array( 'code' => 'número', 'contributor' => 'nº contribuinte', 'create_date' => 'data criação', 'address' => 'morada', 'zip_code' => 'cod. postal', 'city' => 'localidade', 'email' => 'e-mail', 'phone_number' => 'telefone', 'note' => 'observações', ); $validator = validator::make($client, $this->rules,[],$attnames); $validator->setattributenames($attnames); if ($validator->fails()) { // send page input data , errors $errors = $validator->messages(); return redirect::to('/client/create')->withinput()->witherrors($errors); }
you have passed wrong arguments validator::make.
you can pass 3 arguments.
as per documentation,
if needed, may use custom error messages validation instead of defaults. there several ways specify custom messages. first, may pass custom messages third argument validator::make method.
$messages = [ 'required' => 'the :attribute field required.', ]; $validator = validator::make($input, $rules, $messages);
Comments
Post a Comment