Skip to content

Commit

Permalink
[BUGFIX] Properly display boolean values as "0" and "1" in strings
Browse files Browse the repository at this point in the history
The previous implementation used two typecasts in a row: from bool
to string, and from string to bool again. This caused a boolean
false to be cast first to null and then to an empty string instead
of to "0".

Resolves: #89491
Releases: master, 9.5
Change-Id: I4003dfe1e027437fe6366d21cc05453511f85919
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62087
Tested-by: Stefan Froemken <froemken@gmail.com>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
  • Loading branch information
kaystrobach authored and ervaude committed Mar 23, 2020
1 parent 38ac27e commit 3f64343
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -84,6 +84,7 @@ public function render(): array
}
}

$isPublicAsString = $isPublic ? '1' : '0';
$fieldInformationResult = $this->renderFieldInformation();
$fieldInformationHtml = $fieldInformationResult['html'];
$resultArray = $this->mergeChildReturnIntoExistingResult($this->initializeResultArray(), $fieldInformationResult, false);
Expand All @@ -99,17 +100,17 @@ public function render(): array
$html[] = '<input type="checkbox"';
$html[] = ' class="checkbox-input"';
$html[] = ' value="1"';
$html[] = ' data-formengine-input-name="' . htmlspecialchars($parameterArray['itemFormElName']) . '"';
$html[] = ' id="' . htmlspecialchars($checkboxId) . '"';
$html[] = ' data-formengine-input-name="' . htmlspecialchars($parameterArray['itemFormElName'], ENT_QUOTES) . '"';
$html[] = ' id="' . htmlspecialchars($checkboxId, ENT_QUOTES) . '"';
$html[] = $checkboxParameters;
$html[] = $isPublic ? ' checked="checked"' : '';
$html[] = '/>';
$html[] = '<label class="checkbox-label" for="' . htmlspecialchars($checkboxId) . '">';
$html[] = '<span class="checkbox-label-text">' . $this->appendValueToLabelInDebugMode('&nbsp;', $isPublic ? '1' : '0') . '</span>';
$html[] = '<label class="checkbox-label" for="' . htmlspecialchars($checkboxId, ENT_QUOTES) . '">';
$html[] = '<span class="checkbox-label-text">' . $this->appendValueToLabelInDebugMode('&nbsp;', $isPublicAsString) . '</span>';
$html[] = '</label>';
$html[] = '<input type="hidden"';
$html[] = ' name="' . htmlspecialchars($parameterArray['itemFormElName']) . '"';
$html[] = ' value="' . htmlspecialchars((string)$isPublic) . '"';
$html[] = ' name="' . htmlspecialchars($parameterArray['itemFormElName'], ENT_QUOTES) . '"';
$html[] = ' value="' . $isPublicAsString . '"';
$html[] = ' />';
$html[] = '</div>';
$html[] = '</div>';
Expand Down

0 comments on commit 3f64343

Please sign in to comment.