让我说在我看来我有这个:
{{ Form::label('email', 'Email:') }}
{{ Form::text('email', null, ['class' => 'form-control']) }}
{{ errors_for('email', $errors) }}
但不是像以下错误消息:
Your email is not valid
,我想要一个电子邮件的自定义名称,例如电子邮件地址,最后它将是Your email address is not valid
如何为错误消息中的属性设置自定义名称。
我不想创建自定义消息,只是为了设置自定义属性。 by属性我的意思是错误消息中的单词:attribute
,例如:
"alpha" => "The :attribute may only contain letters."
如果我在Laravel中使用Auth
组件进行身份验证,如何做到这一点:
public function create()
{
if (Request::isMethod('post')) {
$input = Input::only('email', 'password');
$this->loginForm->validate($input);
if (Auth::attempt($input))
{
return Redirect::intended('/');
}
// Auth::login($user);
return Redirect::back()->withInput()->with('error', trans('auth.log_in_invalid_credentials'));
}
if (Auth::check()) return Redirect::home();
return View::make('sessions.create');
}
答案 0 :(得分:0)
尝试使用'attributes'
app/lang/en/validation.php
数组
<?php
return array(
// ...
"accepted" => "The :attribute must be accepted.",
"active_url" => "The :attribute is not a valid URL.",
"after" => "The :attribute must be a date after :date.",
"alpha" => "The :attribute may only contain letters.",
// ...
"unique" => "The :attribute has already been taken.",
"url" => "The :attribute format is invalid.",
// ...
'custom' => array(),
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
'attributes' => array(
'email' => 'email address',
),
);