From d4c2d7b7dd33cc05d9eb0c333e5d18c323f064a8 Mon Sep 17 00:00:00 2001 From: albertlast Date: Sun, 9 Aug 2026 11:21:39 +0200 Subject: [PATCH 1/2] Gives every poll choice the same id, whichever code built it Poll::format() handed out ids that already began with "options-", and the two editing templates prefixed them again, so the fields came out as id="options-options-3" name="options[options-3]". Post.php builds Utils::$context['choices'] itself when the posting form comes back from a preview or an error, and it has always used the plain number. So the same form named its fields options[options-0] on the way in and options[0] on the way back, and the option the JS appends never matched either. Nothing broke, because both save paths run array_values() over the submitted options and renumber them by position. It just made the markup impossible to read. Poll::format() now gives the number and leaves the prefix to whoever renders it, which is what Post.php already assumed. Display.template.php and the two SSI poll functions label the vote buttons, whose ids come from format() as well, so they say options- themselves now. Signed-off-by: Mathias Alberts Signed-off-by: albertlast --- Sources/Poll.php | 8 +++++++- Sources/ServerSideIncludes.php | 4 ++-- Themes/default/Display.template.php | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Sources/Poll.php b/Sources/Poll.php index 24e28e13688..6f5591e7168 100644 --- a/Sources/Poll.php +++ b/Sources/Poll.php @@ -426,7 +426,13 @@ public function format(array $format_options = []): array // Now add it to the poll's contextual theme data. $this->formatted['choices'][$i] = [ - 'id' => 'options-' . $i, + // Just the number. Post.php builds this array itself when the + // posting form comes back from a preview or an error, and it + // has always used the plain number, so the templates prefix + // what they need. Handing out 'options-3' here made the same + // form emit id="options-options-3" one way round and + // id="options-3" the other. + 'id' => $i, 'number' => ++$choice_number, 'percent' => $bar, 'votes' => $option->votes, diff --git a/Sources/ServerSideIncludes.php b/Sources/ServerSideIncludes.php index b718bfd78e7..e7352f416bb 100644 --- a/Sources/ServerSideIncludes.php +++ b/Sources/ServerSideIncludes.php @@ -1875,7 +1875,7 @@ public static function recentPoll(bool $topPollInstead = false, string $output_m foreach ($return['options'] as $option) { echo ' -
'; +
'; } echo ' @@ -1966,7 +1966,7 @@ public static function showPoll(?int $topic = null, string $output_method = 'ech foreach ($return['options'] as $option) { echo ' -
'; +
'; } echo ' diff --git a/Themes/default/Display.template.php b/Themes/default/Display.template.php index e3b6ba7f73a..0fca29d0c5f 100644 --- a/Themes/default/Display.template.php +++ b/Themes/default/Display.template.php @@ -148,7 +148,7 @@ function template_main() // Show each option with its button - a radio likely. foreach (Utils::$context['poll']['options'] as $option) { echo ' -
  • ', $option['vote_button'], '
  • '; +
  • ', $option['vote_button'], '
  • '; } echo ' From cb3096710090ed2e98d192d70c080634c4967a5f Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Sat, 29 Aug 2026 18:08:47 -0600 Subject: [PATCH 2/2] Update Sources/Poll.php --- Sources/Poll.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Sources/Poll.php b/Sources/Poll.php index 6f5591e7168..7249b986e4d 100644 --- a/Sources/Poll.php +++ b/Sources/Poll.php @@ -426,12 +426,6 @@ public function format(array $format_options = []): array // Now add it to the poll's contextual theme data. $this->formatted['choices'][$i] = [ - // Just the number. Post.php builds this array itself when the - // posting form comes back from a preview or an error, and it - // has always used the plain number, so the templates prefix - // what they need. Handing out 'options-3' here made the same - // form emit id="options-options-3" one way round and - // id="options-3" the other. 'id' => $i, 'number' => ++$choice_number, 'percent' => $bar,