Commit b5ca61da authored by Shakarim Sapa's avatar Shakarim Sapa

- Добавлено выведение ошибки при валидации;

- Написаны скрипты для обработки добавления и удаления новых полей для загрузки файлов;
parent 0821a887
...@@ -11,6 +11,9 @@ use \yii\bootstrap\Html; ...@@ -11,6 +11,9 @@ use \yii\bootstrap\Html;
echo Html::tag('h2', 'Вложения'); echo Html::tag('h2', 'Вложения');
if ($model->getErrors('file'))
echo Html::tag('span', current($model->getErrors('file')), ['style' => 'color: #ff5b57;']);
echo GridView::widget([ echo GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'options' => [ 'options' => [
...@@ -29,3 +32,13 @@ echo GridView::widget([ ...@@ -29,3 +32,13 @@ echo GridView::widget([
echo Html::button('Добавить файл', ['id' => 'add_file', 'class' => 'btn btn-primary pull-right']); echo Html::button('Добавить файл', ['id' => 'add_file', 'class' => 'btn btn-primary pull-right']);
?> ?>
<script type='text/javascript'>
$(document).on('click', '#add_file', function() {
$('div#lesson-file').children('table').children('tbody').append(
'<tr><td><input type="text" name="AnalyticsSchoolLesson[filename][]" class="form-control"></td><td><input type="file" name="AnalyticsSchoolLesson[file][]"></td><td><input type="button" class="btn btn-warning cancel" value="Отменить"></td></tr>'
);
});
$(document).on('click', 'input.cancel', function() {
$(this).parent('td').parent('tr').remove();
});
</script>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment