[英]How can I save the value of my <input type='checkbox'> to MySQL Database with laravel 5.7 code?
checkbox复选框
<div class="form-check"> <input type="checkbox" name="IF" class="form-check-input"> <label for="IF" class="form-check-label">Ingénieurie de formation</label> <input type="checkbox" name="DS" class="form-check-input"> <label for="DS" class="form-check-label">Diagnostique Stratégique</label> <input type="checkbox" name="PF" class="form-check-input"> <label for="PF" class="form-check-label">Plan de formation</label> </div>
and for my textbox I store it like this对于我的文本框,我是这样存储的
$cl = new Client;
$cl->tel_1 = $request->input('tel_1');
You are getting the value wrong, the index is the name
attribute in html:你得到的值错误,索引是 html 中的
name
属性:
$cl->tel_1 = $request->input('IF');
or或者
<input type="checkbox" name="tel_1" class="form-check-input">
and $cl->tel_1 = $request->input('tel_1');
<input type="checkbox" name="tel_1" class="form-check-input">
和$cl->tel_1 = $request->input('tel_1');
Use value of name attribute from checkbox.使用复选框中的名称属性值。
$checkbox1 = Input::get('IF') //name="IF" $checkbox1 = Input::get('IF') //name="IF"
also, do not forget to add.另外,不要忘记添加。
use Illuminate\\Support\\Facades\\Input;使用 Illuminate\\Support\\Facades\\Input;
You can either use您可以使用
$cl->tel_1 = $_POST['IF'];
Or you can use或者你可以使用
$cl->tel_1 = $_REQUEST['IF'];
as well.以及。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.