Skip to content

Commit

Permalink
Merge pull request #97 from lyz452/patch-1
Browse files Browse the repository at this point in the history
Still trying to make the file input "multiple-files-friendly"
  • Loading branch information
Holt59 authored Jan 6, 2017
2 parents 98cb4ef + ba6f8b4 commit ac54ec3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/View/Helper/BootstrapFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function file($fieldName, array $options = []) {
'id' => $fieldName,
'secure' => true,
'count-label' => __('files selected'),
'button-label' => __('Choose File')
'button-label' => (isset($options['multiple']) && $options['multiple']) ? __('Choose Files') : __('Choose File')
];

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

$fakeInputCustomOptions += [
'value' => $options['val']['name']
];
if (!empty($options['val']) && is_array($options['val'])) {
if (isset($options['val']['name']) || count($options['val']) == 1) {
$fakeInputCustomOptions += [
'value' => (isset($options['val']['name'])) ? $options['val']['name'] : $options['val'][0]['name']
];
}
else {
$fakeInputCustomOptions += [
'value' => count($options['val']) . ' ' . $countLabel
];
}
}

$fakeInput = $this->text($fieldName, array_merge($fakeInputCustomOptions, [
'name' => $fieldName.'-text',
'readonly' => 'readonly',
Expand Down

0 comments on commit ac54ec3

Please sign in to comment.