Skip to content

Commit 9e2b586

Browse files
authored
Bug fix for mutli-value checkboxes in form data.
Checkboxes in form data can have multiple values. Currently the code errors out with "converting array to string" error. This commit fixes that.
1 parent 0422e4d commit 9e2b586

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/Http/Request.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,16 @@ public static function buildPostBody($fields, $files, $boundary = null){
231231
$body = '';
232232

233233
foreach($fields as $name => $value){
234+
//checkboxes can have multiple values in an array.
235+
if(is_array($value)){
236+
foreach($value as $v){
237+
$body .= sprintf($part_field, $boundary, "{$name}[]", $v);
238+
$body .= "{$v}\r\n";
239+
}
240+
} else {
234241
$body .= sprintf($part_field, $boundary, $name, $value);
235242
$body .= "{$value}\r\n";
243+
}
236244
}
237245

238246
// data better have [name, tmp_name, and optional type]
@@ -359,4 +367,4 @@ public static function createFromGlobals(){
359367
}
360368

361369

362-
?>
370+
?>

0 commit comments

Comments
 (0)