|
@@ -145,19 +145,27 @@ class ListField extends Field
|
|
|
$this->script = <<<JS
|
|
|
(function () {
|
|
|
var index = {$number};
|
|
|
- $('.{$this->column}-add').on('click', function () {
|
|
|
- var tpl = $('template.{$this->column}-tpl').html().replace('{key}', index);
|
|
|
- $('tbody.list-{$this->column}-table').append(tpl);
|
|
|
+ $('.{$this->formatColumn()}-add').on('click', function () {
|
|
|
+ var tpl = $('template.{$this->formatColumn()}-tpl').html().replace('{key}', index);
|
|
|
+ $('tbody.list-{$this->formatColumn()}-table').append(tpl);
|
|
|
|
|
|
index++;
|
|
|
});
|
|
|
- $('tbody').on('click', '.{$this->column}-remove', function () {
|
|
|
+ $('tbody').on('click', '.{$this->formatColumn()}-remove', function () {
|
|
|
$(this).closest('tr').remove();
|
|
|
});
|
|
|
})();
|
|
|
JS;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ protected function formatColumn()
|
|
|
+ {
|
|
|
+ return str_replace('.', '-', $this->column);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -181,6 +189,8 @@ JS;
|
|
|
|
|
|
Admin::style('td .form-group {margin-bottom: 0 !important;}');
|
|
|
|
|
|
+ $this->addVariables(['columnClass' => $this->formatColumn()]);
|
|
|
+
|
|
|
return parent::render();
|
|
|
}
|
|
|
}
|