当我使用angularjs和laravel时,我将对象发送到服务器,如下所示,
{
"title": "Title",
"description": "",
"category": {
"id": 1,
"title": "Passport",
"status": 1
}
}
我的表单验证class
是,
protected $rules = [
'title' => ['required', 'max:125'],
'category.id' => ['required', 'integer', 'exists:file_categories,id']
];
它工作正常,但错误信息如下,
The category.id field is required.
我想将其更改为The category field is required.
为此,我更新了validation class
,
'attributes' => [
'category.id' => 'Category',
],
但它不起作用?我该如何解决这个问题?
答案 0 :(得分:0)
试试这个......
在“查看页面”中,您可以替换错误消息文本:
<?php $errmsg=$errors->first('category.id');
$errmessage=str_replace(".id"," ",$errmsg);
if($errmsg !="")
{
?>
<div class="error"><?php echo $errmessage ?></div>
<?php } ?>