Skip to content

Commit f0a8e85

Browse files
committed
add photo upload
1 parent 14d35f6 commit f0a8e85

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

protected/modules/catalog/views/frontend/response/index.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
$('div.group-block[data-form-group != '+group+']').hide();
1010
$('div.group-block[data-form-group = '+group+']').show();
1111
});
12+
13+
$(document).on('click', '.file-container .file-btn', function(){
14+
$('#ResponseForm_photo').click();
15+
}).on('change', '#ResponseForm_photo', function() {
16+
var inputFiles = document.getElementById($(this).prop('id'));
17+
var txt = 'Файл не выбран';
18+
if (inputFiles.files.length == 1)
19+
txt = inputFiles.files[0].name;
20+
21+
$('.file-container .file-name').html(txt);
22+
});
1223
1324
", CClientScript::POS_READY);
1425
?>
@@ -97,9 +108,17 @@
97108
</div>
98109
</div>
99110

100-
<div class="row wp">
101-
<?php echo $form->label($model, 'photo'); ?>:
102-
<?php echo $form->fileField($model, 'photo'); ?>
111+
<div class="row">
112+
<div class="column">
113+
<?php echo $form->label($model, 'photo'); ?>:
114+
<div class="file-container">
115+
<div class="file-name">Файл не выбран</div>
116+
<div class="file-btn">Выберите файл</div>
117+
</div>
118+
<?php echo $form->fileField($model, 'photo'); ?>
119+
</div>
120+
<div class="column">
121+
</div>
103122
</div>
104123

105124
<div class="row wp">

www/css/style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ footer .dev img { max-width: 161px; width: 100%; vertical-align: middle; }
212212
.s-form .row label.error { color: #c90000; }
213213
.s-form .row input.error, .s-form .row select.error { background: #fac2ac; color: #c90000; }
214214

215+
.s-form .row input[type=file] { display: none; }
216+
.s-form .row .file-container { position: relative; color: #000000; }
217+
.s-form .row .file-name { border: 1px solid #e87948; background: #f9eee9; width: 94%; height: 29px; box-shadow: 0 1px 3px rgba(0, 0, 0, .31); border-radius: 0.8em; padding: 0 3%; outline: none; font-family: 'AFuturaRoundDemi'; font-size: 0.9375em; line-height: 29px; }
218+
.s-form .row .file-btn { position: absolute; right: 10px; top: 3px; line-height: 19px; background-color: #a2a3a3; padding: 3px 10px; border-radius: 8px; cursor: pointer; }
219+
215220
.s-form .row .column .column-left input, .s-form .row .column .column-right input { padding: 0 6%; width: 12%; position: absolute; left: 16%; }
216221
.s-form .row .column .column-left select, .s-form .row .column .column-right select { padding: 0 6%; width: 55%; position: absolute; right: 0; }
217222
.s-form .row .column .column-left .text, .s-form .row .column .column-right .text { width: 13%; position: absolute; left: 0; line-height: 31px;text-align: right; padding-right: 3%; }

0 commit comments

Comments
 (0)