Laravel validation attributes “nice names”

后端 未结 10 1769
[愿得一人]
[愿得一人] 2020-12-02 05:41

I\'m trying to use the validation attributes in \"language > {language} > validation.php\", to replace the :attribute name (input name) for a proper to read name (example: f

10条回答
  •  [愿得一人]
    2020-12-02 06:20

    The :attribute can only use the attribute name (first_name in your case), not nice names.

    But you can define custom messages for each attribute+validation by definine messages like this:

    $messages = array(
      'first_name_required' => 'Please supply your first name',
      'last_name_required' => 'Please supply your last name',
      'email_required' => 'We need to know your e-mail address!',
      'email_email' => 'Invalid e-mail address!',
    );
    

提交回复
热议问题