[英]How to pull checkbox information from the form in Laravel 5.4?
I am working on website in Laravel 5.4 in which I am not sure how to pull checkbox information from the form. 我正在Laravel 5.4中的网站上工作,在该网站中我不确定如何从表单中提取复选框信息。
The HTML code copied from the fiddle from where I am using checkbox information is: 从我使用复选框信息的小提琴复制的HTML代码是:
<div class ="form_check_attachments mt-4 ml-2">
<div class="form-group disney_posting_formchecks">
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label" for="gridCheck">
im interested in setting up a <span style="color:rgb(67, 67, 67);font-weight:bold;">pro</span>Store
</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label">
I just want to post a thing or two on disney
</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="gridCheck">
<label class="form-check-label">
I wanted to be notified when the app is live
</label>
</div>
</div>
</div>
The controller code which I am using is: 我正在使用的控制器代码是:
public function store(Request $request)
{
/*
dd($request->all());
*/
$this->validate($request, [
'name' => 'required',
'email' => 'required|email',
'number' => 'required',
'city' => 'required',
'post' => 'required'
]);
Mail::send('emails.posting-message', [
'msg'=> "Name\t" . $request->name . "\r\n"
. "Email\t" . $request->email . "\r\n"
. "Number\t" . $request->number . "\r\n"
. "City\t" . $request->city . "\r\n"
. "Message\t" . $request->post . "\r\n"
], function($mail) use($request) {
$mail->from($request->email, $request->name);
$mail->to('jamalferhan@gmail.com')->subject('Contact Message');
});
return redirect()->back()->with('flash_message', 'thank you, your posting info has been sent to our team. we will reach out as soon as we can to provide next steps!');
}
Problem Statement: 问题陈述:
I am wondering what changes I need to make in the controller so that I am able to pull all the checkbox information. 我想知道我需要在控制器中进行哪些更改,以便能够提取所有复选框信息。 At this moment, it is pulling the values from the input fields only. 目前,它仅从输入字段中提取值。
根据我在代码中看到的内容,您只需要将name属性添加到输入type =“ checkbox”(复选框)中,以便可以看到它们在请求中传递了。
<label class="checkbox-inline">
<input type="checkbox" name="hello" value="hello">Hello
</label>
In controller 在控制器中
$getcheckboxdata = $request->hello;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.