Blame view

common/widgets/views/education_field.php 2.02 KB
a92850cf   Administrator   firs page
1
2
3
4
5
  <?php
  use yii\helpers\Html;
  ?>
  <fieldset>
  
70abf3e7   Administrator   add field v.1
6
      <legend>Образование</legend>
a92850cf   Administrator   firs page
7
8
9
10
  
      <p class="btn btn-success add_field">Добавить поле</p>
  
  
70abf3e7   Administrator   add field v.1
11
12
13
14
15
16
17
18
19
20
21
      <?php for($i=1; $i <= count($model); $i++):
          $row = $i;
          ?>
  
          <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?>
              <input type="text" placeholder="С" class="form-control" value="<?= isset($model[$i]['value']) ? $model[$i]['value'] : '' ?>" name="Fields[education][<?=$row?>][0][year_from]" />
              <input type="text" placeholder="По"  class="form-control" value="<?= isset($model[++$i]['value']) ? $model[$i]['value'] : ''  ?>" name="Fields[education][<?=$row?>][1][year_to]" />
              <textarea placeholder="Место" name="Fields[education][<?=$row?>][2][place]" /><?= isset($model[++$i]['value']) ? $model[$i]['value'] : '' ?></textarea>
              <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')?>
      <?php endfor; ?>
a92850cf   Administrator   firs page
22
  
a92850cf   Administrator   firs page
23
  
a92850cf   Administrator   firs page
24
  
70abf3e7   Administrator   add field v.1
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  </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" >'+
                  '<input type="text" placeholder="С" class="form-control" value="" name="Fields[education]['+ start_i++ +'][0][year_from]" />'+
                  '<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