Skip to content

Commit 77a6c32

Browse files
committed
TermInput: Use sanitized name for element ID
1 parent b8f56d2 commit 77a6c32

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/FormElement/TermInput.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,19 +268,19 @@ public function prepareMultipartUpdate(ServerRequestInterface $request): array
268268
if ($this->valueHasBeenPasted()) {
269269
$updates[] = $this->termContainer();
270270
$updates[] = [
271-
HtmlString::create(json_encode(['#' . $this->getName() . '-search-input', []])),
271+
HtmlString::create(json_encode(['#' . $this->getSanitizedName() . '-search-input', []])),
272272
'Behavior:InputEnrichment'
273273
];
274274
} elseif (! empty($this->changes)) {
275275
$updates[] = [
276-
HtmlString::create(json_encode(['#' . $this->getName() . '-search-input', $this->changes])),
276+
HtmlString::create(json_encode(['#' . $this->getSanitizedName() . '-search-input', $this->changes])),
277277
'Behavior:InputEnrichment'
278278
];
279279
}
280280

281281
if (empty($updates) && $this->hasBeenAutoSubmitted()) {
282282
$updates[] = $updates[] = [
283-
HtmlString::create(json_encode(['#' . $this->getName() . '-search-input', 'bogus'])),
283+
HtmlString::create(json_encode(['#' . $this->getSanitizedName() . '-search-input', 'bogus'])),
284284
'Behavior:InputEnrichment'
285285
];
286286
}
@@ -314,8 +314,8 @@ private function valueHasBeenPasted(): bool
314314

315315
public function onRegistered(Form $form)
316316
{
317-
$termContainerId = $this->getName() . '-terms';
318-
$mainInputId = $this->getName() . '-search-input';
317+
$termContainerId = $this->getSanitizedName() . '-terms';
318+
$mainInputId = $this->getSanitizedName() . '-search-input';
319319
$autoSubmittedBy = $form->getRequest()->getHeader('X-Icinga-Autosubmittedby');
320320

321321
$this->hasBeenAutoSubmitted = in_array($mainInputId, $autoSubmittedBy, true)
@@ -384,15 +384,15 @@ protected function termContainer(): TermContainer
384384
{
385385
if ($this->termContainer === null) {
386386
$this->termContainer = (new TermContainer($this))
387-
->setAttribute('id', $this->getName() . '-terms');
387+
->setAttribute('id', $this->getSanitizedName() . '-terms');
388388
}
389389

390390
return $this->termContainer;
391391
}
392392

393393
protected function assemble()
394394
{
395-
$myName = $this->getName();
395+
$myName = $this->getSanitizedName();
396396

397397
$termInputId = $myName . '-term-input';
398398
$dataInputId = $myName . '-data-input';

0 commit comments

Comments
 (0)