我是使用validate方法进行表单验证的。
$messages = [ 'art_editor.required' => '作者不能为空!', 'art_title.required' => '文章标题不能为空!', 'art_tag.required' => '文章关键字不能为空!', 'art_thumb.required' => '请上传首页图或者添加cdn地址', 'art_description.required' => '文章描述不能为空!', 'art_content.required' => '请填写文章正文!', ];$result = $this->validate($request, [ 'art_editor' => 'required', 'art_title' => 'bail|required|max:25', 'art_tag' => 'required|max:8', 'art_thumb' => 'required', 'art_description' => 'required|max:100', 'art_content' => 'required'], $messages);
但是一旦表单验证失败,虽然会返回失败具体信息,但是正确的那些input内容也都一起被清空了,那如果我写完一篇文章,是文章标题验证失败,那岂不是整篇文章都需要重写? 所以请各位帮忙!谢谢!