[英]Showing validation errors to view
I want to show the validation errors to the users in comma seperated 我想以逗号分隔的方式向用户显示验证错误
ie, 即
The username field is required, The password field is required 用户名字段为必填项,密码字段为必填项
So far i can able to send the validation error messages to the view like this 到目前为止,我可以将验证错误消息发送到这样的视图
$validation->messages()
But the only thing i can't able to do 但是我唯一不能做的
@if(Session::has('Message'))
<p class="alert">{{ Session::get('Message') }}</p>
@endif
or 要么
{{ $errors->first('username', '<div class="error">:message</div>') }}
The only thing i can do is to pass the messages as normal text. 我唯一能做的就是将消息作为普通文本传递。
So, How can i pass the validation messages to a view by plain text (rather than array or object) 因此,我如何通过纯文本(而不是数组或对象)将验证消息传递到视图
Update : 更新:
I mean to say i can do any works only in controller and not in view 我的意思是说我只能在控制器中而不是视野中进行任何工作
在控制器中:
return implode(',',$validation->errors()->all());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.