Skip to content

Commit 7c65893

Browse files
committed
Container::addUpload() parameter $multiple is deprecated
1 parent 0a640e7 commit 7c65893

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Forms/Container.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,13 @@ public function addInteger(string $name, $label = null): Controls\TextInput
285285
* Adds control that allows the user to upload files.
286286
* @param string|object $label
287287
*/
288-
public function addUpload(string $name, $label = null, bool $multiple = false): Controls\UploadControl
288+
public function addUpload(string $name, $label = null): Controls\UploadControl
289289
{
290-
return $this[$name] = new Controls\UploadControl($label, $multiple);
290+
if (func_num_args() > 2) {
291+
trigger_error(__METHOD__ . '() parameter $multiple is deprecated, use addMultiUpload()', E_USER_DEPRECATED);
292+
$multiple = func_get_arg(2);
293+
}
294+
return $this[$name] = new Controls\UploadControl($label, $multiple ?? false);
291295
}
292296

293297

tests/Forms/Controls.UploadControl.render.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test(function () {
3838

3939
test(function () { // multiple
4040
$form = new Form;
41-
$input = $form->addUpload('file', 'Label', true);
41+
$input = $form->addMultiUpload('file', 'Label');
4242

4343
Assert::same('<input type="file" name="file[]" multiple id="frm-file">', (string) $input->getControl());
4444
});

0 commit comments

Comments
 (0)