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>
|
70abf3e7
Administrator
add field v.1
|
7
|
<legend>Образование</legend>
|
a92850cf
Administrator
firs page
|
8
|
|
766bd93b
Yarik
test
|
9
|
<p class="btn btn-success add_field_<?= $this->context->id ?>">Добавить поле</p>
|
a92850cf
Administrator
firs page
|
10
11
|
|
766bd93b
Yarik
test
|
12
13
14
|
<?php $t = 0;
for($i = 1; $i <= count($model); $i++):
$row = $i;
|
ea8c5991
Administrator
add Vitaliy's wid...
|
15
|
|
766bd93b
Yarik
test
|
16
|
?>
|
a92850cf
Administrator
firs page
|
17
|
|
766bd93b
Yarik
test
|
18
19
20
21
22
23
24
25
26
27
28
|
<?= 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[ $t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[education][<?= $row ?>][0][name]"/>
<input type="number" class="form-control" value="<?= isset( $model[ ++$t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[education][<?= $row ?>][1][year_from]"/>
<input type="number" class="form-control" value="<?= isset( $model[ ++$t ][ 'value' ] ) ? $model[ $t ][ 'value' ] : '' ?>" name="Fields[education][<?= $row ?>][2][year_to]"/>
<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
|
29
|
|
a92850cf
Administrator
firs page
|
30
|
|
70abf3e7
Administrator
add field v.1
|
31
32
|
</fieldset>
<script>
|
766bd93b
Yarik
test
|
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
|
var start_i_<?=$this->context->id?> = <?=$i?>;
$ (document)
.ready (
function ()
{
$ ('.add_field_<?=$this->context->id?>')
.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_<?=$this->context->id?>++ + '][0][name]" />' +
'<input type="number" class="form-control" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][1][year_from]" />' +
'<input type="number" class="form-control" value="" name="Fields[education][' + start_i_<?=$this->context->id?>++ + '][2][year_to]" />' +
'<span title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span>' +
'<div>';
console.log (block);
block.append (sub_block);
}
);
}
);
|
70abf3e7
Administrator
add field v.1
|
58
|
</script>
|
a92850cf
Administrator
firs page
|
|
|