Laravel 5.5 - 从多选框中检索所有选定的值

时间:2018-01-24 20:35:09

标签: javascript php laravel-5

我有一个通过JavaScript填充的多选框。提交帖子请求后,尽管有多个选择,但它似乎只存储一个值。如何在发布请求后从Laravel 5.5中的多选框中检索所有选择?

[查看]

public function showResults(Request $request){
    $field = Request::input('customer');

    // dd("Reached POST with:", $field);

    $results = $this->performQuery($field);
    return view('filter', compact('results'));
}

[控制器]

void get_color(Mat img, int x_offset, int y_offset) 
{
    Rect outline(x_offset - 2, y_offset - 2, 5, 5);
    rectangle(img, outline, Scalar(255, 0, 0), 2);

    Rect sample(x_offset, y_offset, 1, 1);
    Mat rgb_image = img(sample);
    Mat hsv_image;
    cvtColor(rgb_image, hsv_image, CV_BGR2HSV);

    Vec3b hsv = hsv_image.at<Vec3b>(0, 0);
    int hue = hsv.val[0]; 
    int saturation = hsv.val[1];
    int value = hsv.val[2];

    printf("H: %d, S: %d, V: %d \n", hue, saturation, value);
}

1 个答案:

答案 0 :(得分:4)

name="customer"更改为name="customer[]"

这会将<select>的值作为数组传递。