@@ -111,16 +111,31 @@ public static function form(): string
111111 if ((bool ) $ user_search_provider ) {
112112 $ name = 'app.options. ' .$ user_search_provider ;
113113 $ provider = self ::providerDetails ($ user_search_provider );
114+ $ providers = self ::providers ();
115+ $ providerCount = count ($ providers );
116+
117+ // If there's only one provider, use its key instead of the user's setting
118+ if ($ providerCount === 1 ) {
119+ $ user_search_provider = $ providers ->keys ()->first ();
120+ }
114121
115122 $ output .= '<div class="searchform"> ' ;
116123 $ output .= '<form action=" ' .url ('search ' ).'" ' .getLinkTargetAttribute ().' method="get"> ' ;
117124 $ output .= '<div id="search-container" class="input-container"> ' ;
118- $ output .= '<select name="provider"> ' ;
119- foreach (self ::providers () as $ key => $ searchprovider ) {
120- $ selected = ((string ) $ key === (string ) $ user_search_provider ) ? ' selected="selected" ' : '' ;
121- $ output .= '<option value=" ' .$ key .'" ' .$ selected .'> ' .$ searchprovider ['name ' ].'</option> ' ;
125+
126+ // Only show dropdown if there's more than one provider
127+ if ($ providerCount > 1 ) {
128+ $ output .= '<select name="provider"> ' ;
129+ foreach ($ providers as $ key => $ searchprovider ) {
130+ $ selected = ((string ) $ key === (string ) $ user_search_provider ) ? ' selected="selected" ' : '' ;
131+ $ output .= '<option value=" ' .$ key .'" ' .$ selected .'> ' .$ searchprovider ['name ' ].'</option> ' ;
132+ }
133+ $ output .= '</select> ' ;
134+ } else {
135+ // Hidden input for single provider
136+ $ output .= '<input type="hidden" name="provider" value=" ' .$ user_search_provider .'" /> ' ;
122137 }
123- $ output .= ' </select> ' ;
138+
124139 $ output .= '<input type="text" name="q" value=" ' .e (Input::get ('q ' ) ?? '' ).'" class="homesearch" autofocus placeholder=" ' .__ ('app.settings.search ' ).'..." /> ' ;
125140 $ output .= '<button type="submit"> ' .ucwords (__ ('app.settings.search ' )).'</button> ' ;
126141 $ output .= '</div> ' ;
0 commit comments