Blame view

common/widgets/views/education_field.php 2.06 KB
a92850cf   Administrator   firs page
1
2
  <?php
  use yii\helpers\Html;
ea8c5991   Administrator   add Vitaliy's wid...
3
  
a92850cf   Administrator   firs page
4
5
6
  ?>
  <fieldset>
  
70abf3e7   Administrator   add field v.1
7
      <legend>Образование</legend>
a92850cf   Administrator   firs page
8
9
10
11
  
      <p class="btn btn-success add_field">Добавить поле</p>
  
  
5a89cabd   Administrator   add Vitaliy's wid...
12
13
14
      <?php
      $t = 0;
      for($i=1; $i <= count($model); $i++):
70abf3e7   Administrator   add field v.1
15
          $row = $i;
ea8c5991   Administrator   add Vitaliy's wid...
16
  
70abf3e7   Administrator   add field v.1
17
18
19
          ?>
  
          <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?>
ea8c5991   Administrator   add Vitaliy's wid...
20
21
22
              <input type="text" placeholder="С" class="form-control" value="<?= isset($model[$t]['value']) ? $model[$t]['value'] : '' ?>" name="Fields[education][<?=$row?>][0][year_from]" />
              <input type="text" placeholder="По"  class="form-control" value="<?= isset($model[++$t]['value']) ? $model[$t]['value'] : ''  ?>" name="Fields[education][<?=$row?>][1][year_to]" />
              <textarea placeholder="Место" name="Fields[education][<?=$row?>][2][place]" /><?= isset($model[++$t]['value']) ? $model[$t]['value'] : '' ?></textarea>
70abf3e7   Administrator   add field v.1
23
24
              <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>
          <?= Html::endTag('div')?>
ea8c5991   Administrator   add Vitaliy's wid...
25
          <?php $i = ++ $t; ?>
70abf3e7   Administrator   add field v.1
26
      <?php endfor; ?>
a92850cf   Administrator   firs page
27
  
a92850cf   Administrator   firs page
28
  
a92850cf   Administrator   firs page
29
  
70abf3e7   Administrator   add field v.1
30
31
32
33
34
35
36
37
  </fieldset>
  <script>
      $( document ).ready(function(){
          var start_i = <?=$i?>;
          $('.add_field').click(function(){
              var block = $(this).parent('fieldset');
              var block_id =  $(this).parent('fieldset');
              var sub_block = '<div class="form-group" >'+
ea8c5991   Administrator   add Vitaliy's wid...
38
                  '<input type="text" placeholder="С" class="form-control" value="" name="Fields[education]['+ ++start_i +'][0][year_from]" />'+
70abf3e7   Administrator   add field v.1
39
40
41
42
43
44
45
46
47
                  '<input type="text" placeholder="По"  class="form-control" value="" name="Fields[education]['+ start_i +'][1][year_to]" />'+
                  '<textarea placeholder="Место" name="Fields[education]['+ start_i +'][2][place]" /></textarea>'+
                  '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>'+
                  '<div>';
              block.append(sub_block);
  
          });
      });
  </script>
a92850cf   Administrator   firs page