我正在Laravel 5.4中的网站上工作,在该网站中我不确定如何从表单中提取复选框信息。
从我使用复选框信息的fiddle复制的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>
我正在使用的控制器代码是:
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!');
}
问题陈述:
我想知道我需要在控制器中进行哪些更改,以便能够提取所有复选框信息。目前,它仅从输入字段中提取值。
答案 0 :(得分:2)
根据我在代码中看到的内容,只需将 name属性添加到输入type =“ checkbox”(复选框)中,以便可以看到它们在请求中传递。 / p>
答案 1 :(得分:0)
from imutils.video import VideoStream
from imutils import face_utils
import datetime
import argparse
import imutils
import time
import dlib
import cv2
import numpy as np
# path to facial landmark predictor
ap = argparse.ArgumentParser()
ap.add_argument("-p", "--shape-predictor", required=True)
print("[INFO] loading facial landmark predictor...")
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(args["shape_predictor"])
# grab the indexes of the facial landmarks
(lebStart, lebEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eyebrow"]
(rebStart, rebEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eyebrow"]
(jawStart, jawEnd) = face_utils.FACIAL_LANDMARKS_IDXS["jaw"]
# initialize the video stream and allow the cammera sensor to warmup
print("[INFO] camera sensor warming up...")
vs = VideoStream(usePiCamera=args["picamera"] > 0).start()
time.sleep(2.0)
# loop over the frames from the video stream
while True:
# grab the frame from the threaded video stream, resize it to
# have a maximum width of 400 pixels, and convert it to
# grayscale
frame = vs.read()
frame = imutils.resize(frame, width=400)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# detect faces in the grayscale frame
rects = detector(gray, 0)
# loop over the face detections
for rect in rects:
shape = predictor(gray, rect)
shape = face_utils.shape_to_np(shape)
# extract the face coordinates, then use the
faceline = shape[jawStart:lebEnd]
# compute the convex hull for face, then
# visualize each of the face
facelineHull = cv2.convexHull(faceline)
mask = np.zeros(frame.shape,dtype='uint8')
cv2.drawContours(frame, [facelineHull], -1, (0, 0, 0),thickness=cv2.FILLED)
cv2.drawContours(frame, [facelineHull], -1, (0, 255, 0))
# show the frame
cv2.imshow("Frame", frame)
# cv2.imshow("Frame", mask)
key = cv2.waitKey(1) & 0xFF
# if the `q` key was pressed, break from the loop
if key == ord("q"):
break
# do a bit of cleanup
cv2.destroyAllWindows()
vs.stop()
在控制器中
<label class="checkbox-inline">
<input type="checkbox" name="hello" value="hello">Hello
</label>