Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** ===== FILE: app\Http\Requests\validateFormDocument ====== */
- public function rules()
- {
- return [
- 'caption.*' => 'required',
- 'jenis.*' => 'required',
- 'gambar.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
- ];
- }
- public function messages()
- {
- // ??? Custom validation messages nya seperti apa..?
- }
- /** ===== FILE: app\Http\Controllers\Document ======= */
- public function store(validateFormDocument $request)
- {
- ...
- }
- /** ===== FILE: resources\views\form ======= */
- <form id="formnya" method="POST" action="route('doc.store')" enctype="multipart/form-data">
- @csrf
- <input type="text" name="docname" >
- <!-- disini sebenarnya gambar bertambah ketika addRow button menggunakan Javascript
- tapi anggap saja gambar sudah ada di form.
- -->
- <div id="rowGambar">
- <div id="row_1">
- <input type="text" name="caption[]" >
- <input type="text" name="jenis[]" >
- <input type="file" name="gambar[]"
- </div>
- <div id="row_2">
- <input type="text" name="caption[]" >
- <input type="text" name="jenis[]" >
- <input type="file" name="gambar[]"
- </div>
- <div id="row_3">
- <input type="text" name="caption[]" >
- <input type="text" name="jenis[]" >
- <input type="file" name="gambar[]"
- </div>
- </div>
- </form>
Add Comment
Please, Sign In to add comment