From 2367268b4b8da9ca21f01e7f322b472ad17c98ea Mon Sep 17 00:00:00 2001 From: Torben Dannhauer Date: Wed, 17 Dec 2025 22:11:34 +0100 Subject: [PATCH] Improve init method to support associative array prompt Enhance init method to handle associative arrays for prompt. --- lib/Horde/Form/Type.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/Horde/Form/Type.php b/lib/Horde/Form/Type.php index 1c933ef..2f08f7f 100644 --- a/lib/Horde/Form/Type.php +++ b/lib/Horde/Form/Type.php @@ -963,9 +963,23 @@ class Horde_Form_Type_country extends Horde_Form_Type_enum * * function init($prompt = null) */ - public function init(...$params) - { - $prompt = $params[0] ?? null; +public function init(...$params) + { + // When call_user_func_array passes an associative array like ['prompt' => 1], + // and the function uses ...$params, PHP passes the array as a single argument, + // but $params itself becomes the associative array directly (not $params[0]) + // So we need to check if $params itself has the 'prompt' key + $prompt = null; + if (is_array($params) && isset($params['prompt'])) { + // $params is directly the associative array with 'prompt' key + $prompt = $params['prompt']; + } elseif (isset($params[0]) && is_array($params[0]) && isset($params[0]['prompt'])) { + // $params[0] is an array with 'prompt' key (fallback for numeric arrays) + $prompt = $params[0]['prompt']; + } elseif (isset($params[0]) && !is_array($params[0])) { + // Direct value passed as first argument + $prompt = $params[0]; + } parent::init(Horde_Nls::getCountryISO(), $prompt); }