From 117f0da125598643fb6f7769c882a9c346b0f3ff Mon Sep 17 00:00:00 2001 From: Alex Schmitz Date: Sat, 28 Aug 2021 10:01:05 +0200 Subject: [PATCH] Fix key casting in form_dropdown helper. --- system/Helpers/form_helper.php | 6 +++++- tests/system/Helpers/FormHelperTest.php | 28 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index bb4f6cd8060f..e33ec2e89137 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -298,7 +298,7 @@ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): } } - // standardize selected as strings, like the option keys will be. + // Standardize selected as strings, like the option keys will be foreach ($selected as $key => $item) { $selected[$key] = (string) $item; } @@ -308,6 +308,7 @@ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): $form = '\n + EOH; + $this->assertSame($expected, form_dropdown('cars', $options, $selected)); + } + public function testFormDropdownInferred() { $options = [