0
動的フォームの検証を作成するにはどうすればよいですか?動的フォームでの検証Laravel 5.5
//Controller
public function store(Request $request)
{
$rules = [
'companyName' => 'required',
'bannerName' => 'required',
'bannerDescription' => 'required',
'bannerURL' => 'required',
'bannerImg' => 'required',
];
$customMessages = [
'companyName.required' => 'Yo, what should I call you?',
'bannerName.required' => 'Yo, what should I call you?',
'bannerDescription.required' => 'Yo, what should I call you?',
'bannerURL.required' => 'Yo, what should I call you?',
'bannerImg.required' => 'Yo, what should I call you?',
];
$this->validate($request, $rules, $customMessages);
}
私の見解では、私の「名前」attrは配列なので、大量のデータをDBに保存します。 "+バナーを追加"をクリックすると、jqueryは同じ4つの入力でdivを複製します。 私はすべてがOFCを動作するのアレイを削除します場合は、しかし、何も私は
はhtmlspecialchars(次のエラーを取得していないよ場合)、パラメータ1が
{!! Form::open(['action' => '[email protected]', 'method' => 'POST', 'enctype' => 'multipart/form-data']) !!}
<div class="form-group{{ $errors->has('companyName') ? ' has-error' : '' }}">
<label for="companyName">Company URL Address</label>
<input type="text" class="form-control" value="{{old('companyName')}}" id="companyName" name="companyName" placeholder="example.com">
<small class="text-danger">{{ $errors->first('companyName') }}</small>
</div>
<hr>
<div data-sel-baner-box>
<div data-sel-baner-form>
<div class="panel-heading"><h4 style="text-align: center">New banner</h4></div>
<div class="form-group{{ $errors->has('bannerName') ? ' has-error' : '' }}">
<label for="bannerName">Title</label>
<input type="text" class="form-control" id="bannerName" value="{{old('bannerName')}}" name="bannerName[]" placeholder="Name">
<small class="text-danger">{{ $errors->first('bannerName') }}</small>
</div>
<div class="form-group{{ $errors->has('bannerDescription') ? ' has-error' : '' }}">
<label for="bannerDescription">Banner Description</label>
<input type="text" class="form-control" id="bannerDescription" value="{{old('bannerDescription')}}" name="bannerDescription[]" placeholder="Description">
<small class="text-danger">{{ $errors->first('bannerDescription') }}</small>
</div>
<div class="form-group{{ $errors->has('bannerURL') ? ' has-error' : '' }}">
<label for="bannerURL">Banner URL</label>
<input type="text" class="form-control" id="bannerURL" value="{{old('bannerURL')}}" name="bannerURL[]" placeholder="URL">
<small class="text-danger">{{ $errors->first('bannerURL') }}</small>
</div>
<div class="form-group{{ $errors->has('bannerImg') ? ' has-error' : '' }}">
<label for="bannerImg">File input</label>
<input type="file" class="form-control-file" id="bannerImg" name="bannerImg[]">
<small class="text-danger">{{ $errors->first('bannerImg') }}</small>
</div>
</div>
<a href="##" data-sel-btn-add-baner class="btn btn-primary">+ Add Banner</a>
<button type="submit" class="btn btn-primary">Save Company</button>
{!! Form::close() !!}
任意の与えられた文字列、配列であることを期待ヒントはどうですか?
返信いただきありがとうございます。 私はこれをしようとしましたが、うまくいきません。それでも同じエラーがあります。 – qqmydarling
@qqmydarling検証の方法は、私が上で述べたものです。あなたのエラーは、いくつかの空のデータなどのためにHTMLビューにあります。 –
そして、エラーはどの行に追加できますか? –