Blame view

common/widgets/views/requirements_field.php 2.25 KB
eb7e82fb   Administrator   29.02.16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  <?php

      use yii\helpers\Html;

  

  ?>

  <fieldset>

  

      <div class="skills-title">Требования</div>

  

      <div class="field_list">

  

  

      <?php $t = 0;

          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 custom-input-2" value="<?= isset( $model[ $t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[requirements][<?= $row ?>][0][requirements]"/>

              <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; ?>

  

      </div>

a41edafc   Yarik   test
29
      <p class="btn btn-success add_field_<?= $this->context->id ?>">Добавить еще</p>

eb7e82fb   Administrator   29.02.16
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  </fieldset>

  <script>

      var start_i_<?=$this->context->id?> = <?=$i?>;

      $ (document)

          .ready (

              function ()

              {

                  $ ('.add_field_<?=$this->context->id?>')

                      .click (

                          function ()

                          {

                              var block     = $ (this)

                                  .siblings('.field_list');

                              var block_id  = $ (this)

                                  .parent ('fieldset');

                              var sub_block = '<div class="form-group" >' +

                                              '<input type="text" placeholder="" class="form-control custom-input-2" value="" name="Fields[requirements][' + start_i_<?=$this->context->id?>++ + '][0][requirements]" />' +

                                              '<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' +

                                              '<div>';

                              console.log (block);

                              block.append (sub_block);

                          }

                      );

              }

          );

  </script>