Home >Backend Development >PHP Tutorial >Laravel form validation fails. How to prevent the original form data from being cleared?
I use the validate method for form verification.
<code>$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);</code>
But once the form verification fails, although the specific failure information will be returned, the correct input content will also be cleared. So if I finish writing an article and the article title fails to be verified, wouldn’t the entire article need to be verified? Rewrite? So please help! Thanks!