Blame view

common/widgets/views/education_field.php 4.64 KB
a92850cf   Administrator   firs page
1
  <?php
766bd93b   Yarik   test
2
      use yii\helpers\Html;
ea8c5991   Administrator   add Vitaliy's wid...
3
  
a92850cf   Administrator   firs page
4
5
6
  ?>
  <fieldset>
  
98a795fb   Виталий   tokar commit
7
  <div class="skills-title">Образование</div>
a92850cf   Administrator   firs page
8
  
658d13d4   Administrator   09.02.16
9
      <div class="field_list">
a92850cf   Administrator   firs page
10
  
766bd93b   Yarik   test
11
      <?php $t = 0;
161155ac   Administrator   09.02.16
12
13
  
          $label = 0; // add this var
5d163f4b   Administrator   09.02.16
14
  
766bd93b   Yarik   test
15
16
          for($i = 1; $i <= count($model); $i++):
              $row = $i;
ea8c5991   Administrator   add Vitaliy's wid...
17
  
766bd93b   Yarik   test
18
              ?>
a92850cf   Administrator   firs page
19
  
766bd93b   Yarik   test
20
21
22
23
              <?= Html::beginTag('div', [
              'class' => 'form-group',
              'id'    => isset( $model[ $i ][ 'parent_key' ] ) ? $model[ $i ][ 'parent_key' ] : 0,
          ]) ?>
b2743529   Виталий   tokar commit
24
25
26
27
28
29
30
31
32
33
34
35
              <div class="input-blocks">
                  <input id="edu-name-<?= ++$label  ?>" type="text" placeholder="Название" class="form-control custom-input-2" value="<?= isset( $model[ $t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[education][<?= $row ?>][0][name]"/>
                  <label for="edu-name-<?= $label ?>">Название ВУЗа</label>
               </div>
              <div class="input-blocks">
                  <input id="edu-to-<?= ++$label ?>" type="number" class="form-control form-control custom-input-2 custom-input-2-date" value="<?= isset( $model[ ++$t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[education][<?= $row ?>][1][year_from]"/>
                  <label for="edu-to-<?= $label ?>">год начала</label>
              </div>
              <div class="input-blocks">
                  <input id="edu-out-<?= ++$label ?>" type="number" class="form-control form-control custom-input-2 custom-input-2-date" value="<?= isset( $model[ ++$t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[education][<?= $row ?>][2][year_to]"/>
                  <label for="edu-out-<?= $label ?>">год окончания</label>
              </div>
766bd93b   Yarik   test
36
37
38
39
              <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 $i = ++$t; ?>
          <?php endfor; ?>
a92850cf   Administrator   firs page
40
  
658d13d4   Administrator   09.02.16
41
      </div>
b2743529   Виталий   tokar commit
42
      <p class="btn btn-success add_field_<?= $this->context->id ?>">добавить еще</p>
70abf3e7   Administrator   add field v.1
43
  </fieldset>
98a795fb   Виталий   tokar commit
44
  
70abf3e7   Administrator   add field v.1
45
  <script>
766bd93b   Yarik   test
46
      var start_i_<?=$this->context->id?> = <?=$i?>;
161155ac   Administrator   09.02.16
47
      var start_label_<?=$this->context->id?> = <?=$label?>; // add this var
766bd93b   Yarik   test
48
49
50
51
52
53
54
55
56
      $ (document)
          .ready (
              function ()
              {
                  $ ('.add_field_<?=$this->context->id?>')
                      .click (
                          function ()
                          {
                              var block     = $ (this)
658d13d4   Administrator   09.02.16
57
                                  .siblings('.field_list');
766bd93b   Yarik   test
58
59
60
                              var block_id  = $ (this)
                                  .parent ('fieldset');
                              var sub_block = '<div class="form-group" >' +
b2743529   Виталий   tokar commit
61
62
63
64
65
66
67
68
69
                                              '<div class="input-blocks">'+
                                              '<input id="edu-name-' + ++start_label_<?=$this->context->id?> +'" type="text" placeholder="" class="form-control custom-input-2" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][0][name]" />' +
                                              '<label for="edu-name-' + start_label_<?=$this->context->id?> +'">Название ВУЗа</label>'+
                                              '</div>'+
                                              '<div class="input-blocks">'+
                                              '<input id="edu-to-' + ++start_label_<?=$this->context->id?> +'" type="number" class="form-control custom-input-2 custom-input-2-date" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][1][year_from]" />' +
                                              '<label for="edu-to-' + start_label_<?=$this->context->id?>  +'">год начала</label>'+
                                              '</div>'+
                                              '<div class="input-blocks">'+
5d163f4b   Administrator   09.02.16
70
                                              '<input id="edu-out-' + ++start_label_<?=$this->context->id?>  +'"" type="number" class="form-control custom-input-2 custom-input-2-date" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][2][year_to]" />' +
b2743529   Виталий   tokar commit
71
72
                                              '<label for="edu-out-' + start_label_<?=$this->context->id?> +'">год окончания</label>'+
                                              '</div>'+
766bd93b   Yarik   test
73
74
75
76
77
78
79
80
                                              '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' +
                                              '<div>';
                              console.log (block);
                              block.append (sub_block);
                          }
                      );
              }
          );
70abf3e7   Administrator   add field v.1
81
  </script>
a92850cf   Administrator   firs page