Skip to content

Commit 0ab288e

Browse files
author
Eugene Tupikov
committed
Rename placeholders
1 parent dfd203f commit 0ab288e

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/MultipleInput.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private function getRowTemplate()
207207
$hiddenInputs = [];
208208
foreach ($this->columns as $columnIndex => $column) {
209209
/* @var $column MultipleInputColumn */
210-
$value = $column->name . '_value';
210+
$value = 'multiple-' . $column->name . '-value';
211211
$this->replacementKeys[$value] = $column->defaultValue;
212212
$value = '{' . $value . '}';
213213

@@ -238,7 +238,7 @@ private function collectJsTemplates()
238238
{
239239
$this->jsTemplates = [];
240240
foreach ($this->getView()->js[View::POS_READY] as $key => $js) {
241-
if (preg_match('/\(.#[^)]+{index}[^)]+\)/', $js) === 1) {
241+
if (preg_match('/\(.#[^)]+{multiple-index}[^)]+\)/', $js) === 1) {
242242
$this->jsTemplates[] = $js;
243243
unset($this->getView()->js[View::POS_READY][$key]);
244244
}
@@ -257,10 +257,10 @@ private function renderActionColumn()
257257
[
258258
'tagName' => 'div',
259259
'encodeLabel' => false,
260-
'label' => Html::tag('i', null, ['class' => 'glyphicon glyphicon-{btn_action}']),
260+
'label' => Html::tag('i', null, ['class' => 'glyphicon glyphicon-{multiple-btn-action}']),
261261
'options' => [
262262
'id' => $this->getElementId('button'),
263-
'class' => "{btn_type} multiple-input-list__btn btn js-input-{btn_action}",
263+
'class' => "{multiple-btn-type} multiple-input-list__btn btn js-input-{multiple-btn-action}",
264264
]
265265
]
266266
);
@@ -281,19 +281,19 @@ private function renderRow($index, $data = null)
281281
{
282282
$btnAction = $index == 0 ? self::ACTION_ADD : self::ACTION_REMOVE;
283283
$btnType = $index == 0 ? 'btn-default' : 'btn-danger';
284-
$search = ['{index}', '{btn_action}', '{btn_type}'];
284+
$search = ['{multiple-index}', '{multiple-btn-action}', '{multiple-btn-type}'];
285285
$replace = [$index, $btnAction, $btnType];
286286

287287
foreach ($this->columns as $column) {
288288
/* @var $column MultipleInputColumn */
289-
$search[] = '{' . $column->name . '_value}';
289+
$search[] = '{multiple-' . $column->name . '-value}';
290290
$replace[] = $column->prepareValue($data);
291291
}
292292

293293
$row = str_replace($search, $replace, $this->getRowTemplate());
294294

295295
foreach ($this->jsTemplates as $js) {
296-
$this->getView()->registerJs(strtr($js, ['{index}' => $index]), View::POS_READY);
296+
$this->getView()->registerJs(strtr($js, ['{multiple-index}' => $index]), View::POS_READY);
297297
}
298298
return $row;
299299
}
@@ -308,7 +308,7 @@ private function renderRow($index, $data = null)
308308
public function getElementName($name, $index = null)
309309
{
310310
if ($index === null) {
311-
$index = '{index}';
311+
$index = '{multiple-index}';
312312
}
313313
return $this->getInputNamePrefix($name) . (
314314
count($this->columns) > 1
@@ -367,8 +367,8 @@ public function registerClientScript()
367367
'id' => $this->getId(),
368368
'template' => $this->getRowTemplate(),
369369
'jsTemplates' => $this->jsTemplates,
370-
'btn_action' => self::ACTION_REMOVE,
371-
'btn_type' => 'btn-danger',
370+
'btnAction' => self::ACTION_REMOVE,
371+
'btnType' => 'btn-danger',
372372
'limit' => $this->limit,
373373
'replacement' => $this->replacementKeys,
374374
]

src/assets/src/js/jquery.multipleInput.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
id: null,
1515
template: null,
1616
jsTemplates: [],
17-
btn_action: null,
18-
btn_type: null,
17+
btnAction: null,
18+
btnType: null,
1919
limit: 1,
2020
replacement: []
2121
};
@@ -78,8 +78,8 @@
7878
if (settings.limit != null && count >= settings.limit) {
7979
return;
8080
}
81-
var search = ['{index}', '{btn_action}', '{btn_type}', '{value}'],
82-
replace = [data.currentIndex, settings.btn_action, settings.btn_type, ''];
81+
var search = ['{multiple-index}', '{multiple-btn-action}', '{multiple-btn-type}', '{multiple-value}'],
82+
replace = [data.currentIndex, settings.btnAction, settings.btnType, ''];
8383

8484
for (var i in search) {
8585
template = template.replaceAll(search[i], replace[i]);
@@ -96,7 +96,7 @@
9696

9797
var jsTemplate;
9898
for (i in settings.jsTemplates) {
99-
jsTemplate = settings.jsTemplates[i].replaceAll('{index}', data.currentIndex);
99+
jsTemplate = settings.jsTemplates[i].replaceAll('{multiple-index}', data.currentIndex);
100100
window.eval(jsTemplate);
101101
}
102102
wrapper.data('multipleInput').currentIndex++;

0 commit comments

Comments
 (0)