提交按钮在 col-4 中放置时处于非活动状态,但表单在 col-8 laravel 中提交



<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-8">
<form action="action" method="post">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this submits the form
</div>
	 <div class="col-4">
		   <button type="submit" class="btn btn-success">Submit your Post</button>  //this is inactive and doesn't submit the form
		</div>
	</form>
	</div>

引导程序的 col 标签工作得很奇怪,提交按钮在类似的意义上不起作用。

<div class="row">
<div class="col-8">
<form action="action" method="post">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this is inactive and doesn't submit the form
</div>
</form>
</div>

您在代码中遗漏了,您需要在<div class="col-8">之前粘贴此<form action="action" method="post">标签

试试这个

<div class="row">
<form action="action" method="post">
<div class="col-8">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this is inactive and doesn't submit the form
</div>
</form>
</div>

html close标签是错误的,如果你想提交按钮form但仍然是表单的一部分,必须这样做:

<div class="row">
<div class="col-8">
<form id="my-form" action="action" method="post">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this submits the form
</form>
</div>
<div class="col-4">
<button type="submit" class="btn btn-success" form="my-form">Submit your Post</button>  //this is inactive and doesn't submit the form
</div>

我为表格设置id

<form id="my-form" action="action" method="post">

然后为按钮提交设置form属性:

<button type="submit" class="btn btn-success" form="my-form">Submit your Post</button>

或者您可以尝试其他方式,如下所示:

<div class="row">
<form action="action" method="post">
<div class="col-8">
<input type="text" class="form-control" name="title">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this submits the form
</div>
<div class="col-4">
<button type="submit" class="btn btn-success">Submit your Post</button>  //this is inactive and doesn't submit the form
</div>
</form>

最新更新