Home  >  Article  >  Backend Development  >  Laravel form validation fails. How to prevent the original form data from being cleared?

Laravel form validation fails. How to prevent the original form data from being cleared?

WBOY
WBOYOriginal
2016-08-29 08:35:531674browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn