Skip to content

Commit ac54ec3

Browse files
authoredJan 6, 2017
Merge pull request #97 from lyz452/patch-1
Still trying to make the file input "multiple-files-friendly"
2 parents 98cb4ef + ba6f8b4 commit ac54ec3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed
 

‎src/View/Helper/BootstrapFormHelper.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public function file($fieldName, array $options = []) {
395395
'id' => $fieldName,
396396
'secure' => true,
397397
'count-label' => __('files selected'),
398-
'button-label' => __('Choose File')
398+
'button-label' => (isset($options['multiple']) && $options['multiple']) ? __('Choose Files') : __('Choose File')
399399
];
400400

401401
$fakeInputCustomOptions = $options['_input'];
@@ -412,9 +412,19 @@ public function file($fieldName, array $options = []) {
412412
'escape' => false
413413
]));
414414

415-
$fakeInputCustomOptions += [
416-
'value' => $options['val']['name']
417-
];
415+
if (!empty($options['val']) && is_array($options['val'])) {
416+
if (isset($options['val']['name']) || count($options['val']) == 1) {
417+
$fakeInputCustomOptions += [
418+
'value' => (isset($options['val']['name'])) ? $options['val']['name'] : $options['val'][0]['name']
419+
];
420+
}
421+
else {
422+
$fakeInputCustomOptions += [
423+
'value' => count($options['val']) . ' ' . $countLabel
424+
];
425+
}
426+
}
427+
418428
$fakeInput = $this->text($fieldName, array_merge($fakeInputCustomOptions, [
419429
'name' => $fieldName.'-text',
420430
'readonly' => 'readonly',

0 commit comments

Comments
 (0)