我正在使用Laravel 5.4 Framework,当form
除了csrf_token()
之外没有提交任何内容时,我就会遇到此问题。
如果我将input
放在那些<div>
之外,它会工作并提交,否则浏览器(Chrome)只会提交令牌,就好像<div>
内的所有内容都是不是表格的一部分。
如何在使用Bootstrap的form-group
div时提交所有数据?布局不是问题,因为即使在删除它时它也不起作用。
@extends(&#39; layouts.master&#39)
@section('content')
<div class="container" style="margin-top: 1%">
<p>Welcome, {{$user->name}}, here you can submit a new company for our database.</p>
<form name="suggestCompanyForm" method="post">
{{csrf_field()}}
<div class="form-group">
<label for="companyName">Company Name</label>
<input type="text" class="form-control" id="companyName" aria-describedby="companyNameHelp" placeholder="Enter company name">
<small id="companyNameHelp" class="form-text text-muted">Enter the company's name you would like to suggest</small>
</div>
<div class="form-group">
<label for="companyEmail">Email address</label>
<input type="email" class="form-control" id="companyEmail" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">Enter the company contact email.</small>
</div>
<div class="form-group">
<label for="selectCategory">Select main category</label>
<select class="form-control" id="selectCategory">
<option>Food&Drink</option>
<option>Cosmetics</option>
<option>Electronics</option>
<option>Consumer Goods</option>
<option>Services</option>
</select>
</div>
<div class="form-group">
<label for="description">Company description.</label>
<textarea class="form-control" id="description" rows="5"></textarea>
</div>
<div class="form-group">
<label for="logo">File input</label>
<input type="file" class="form-control-file" id="logo" aria-describedby="logoHelp">
<small id="fileHelp" class="form-text text-muted">Add company logo.</small>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="check" class="form-check-input">
I agree that my submission follows the website rules.
</label>
</div>
<button id="submitCompany" type="submit" class="btn btn-primary" >Submit</button>
</form>
</div>
@endsection
答案 0 :(得分:2)
您的表单输入未提交,因为您没有提供姓名......
尝试
<textarea class="form-control" name="description" id="description" rows="5"></textarea>
答案 1 :(得分:1)
您必须将action属性添加到表单标记。 编辑此行
<form name="suggestCompanyForm" method="post">
到
<form name="suggestCompanyForm" action = "<url-for-the-submission>" method="post">
。您还需要添加此
name="name_of_input_to_submit"
每个输入不仅是textarea,而且你还要上传一个文件,你必须将它添加到表格标签。
enctype="multipart/form-data"