0
후 검증과 laravel 양식을 비어 가고, 여기에 문제는 빈 필드를 떠날 때 오류 메시지 (즉, 괜찮아)하지만 표시이다 나는 몇 가지 필드 그것을 다른 사람들이하지 그것을 채울 경우 새로 고침을 만든 다음 이제 충전 된 필드는 비어 있고 해당 필드에 대한 오류 메시지가 너무 표시됩니다.채워진 필드는 내가 만든 검증
public function store() {
$data = [
"errors" => null
];
$rules = array(
"car" => "required|unique:insur_docs,car_id",
"ownership_cert" => "required",
"authoriz" => "required",
"drive_permis" => "required",
"sgs" => "required",
"tpl" => "required",
"kasko" => "required",
"inter_permis" => "required",
);
$validation = Validator::make(Input::all(), $rules);
$cars = DB::table('cars')->orderBy('Description', 'asc')->distinct()->lists('Description', 'id');
if ($validation->passes()) {
$doc = new InsurDoc();
$doc->ownership_cert = Input::get('ownership_cert');
$doc->authoriz = Input::get('authoriz');
$doc->drive_permis = Input::get('drive_permis');
$doc->sgs = Input::get('sgs');
$doc->tpl = Input::get('tpl');
$doc->kasko = Input::get('kasko');
$doc->inter_permis = Input::get('inter_permis');
$doc->car_id = Input::get('car');
$doc->save();
return Redirect::to('/');
} else {
$data['errors'] = $validation->errors();
$data['cars'] = $cars;
return View::make('pages.insur_docs_create', $data);
}
}
보기
@if($errors->count() > 0)
<div class="alert alert-danger">
<p>The following errors have occurred:</p>
<ul>
@foreach($errors->all() as $message)
<li>{{ Helpers\Helper::macro($message) }}</li>
@endforeach
</ul>
</div>
@endif
매크로 기능은
public static function macro($errors) {
return "<span class=\"glyphicon glyphicon-warning-sign\">"
. "</span> $errors";
}
잘못이 무엇 이죠?
감사합니다.이 페이지의 새로 고침을 실행하면 아무런 필드도 표시되지 않습니다./왜냐하면 우리는 저장소에 유효성 검사를 넣고 있기 때문입니까? –
어떤 아이디어는 어떻게이 문제를 해결하려면? 페이지가 새로 고침 할 때 동일하게합니까? –