summaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-05-24 19:33:07 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-05-24 19:33:07 +0200
commit9694c61f301989cdbbfd9e303e74b30812752cab (patch)
treec8985aec611358f08ea817f3e58487ffd708159d /includes
parentc65980879a990e6d02a8ab262b014e670f314477 (diff)
downloadgigologadmin-9694c61f301989cdbbfd9e303e74b30812752cab.tar.gz
gigologadmin-9694c61f301989cdbbfd9e303e74b30812752cab.tar.bz2
gigologadmin-9694c61f301989cdbbfd9e303e74b30812752cab.zip
Allow custom text for no selection in select_fields.
Diffstat (limited to 'includes')
-rw-r--r--includes/view-helpers/select_field.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/includes/view-helpers/select_field.php b/includes/view-helpers/select_field.php
index 7cff3ef..816f8ef 100644
--- a/includes/view-helpers/select_field.php
+++ b/includes/view-helpers/select_field.php
@@ -13,11 +13,17 @@ namespace EternalTerror\ViewHelpers;
* @param array $opts The options as arrays of [value, label] pairs
* @param mixed|int $selected The value of the preselected option, or null if no
* option is preselected.
+ * @param string $blank Text to use for "no selection", defaults to "Please
+ * select..."
* @return string
*/
-function select_field(string $name, ?array $opts = [], $selected = null) : string
+function select_field(
+ string $name,
+ ?array $opts = [],
+ $selected = null,
+ string $blank = "Please select...") : string
{
- $body = '';
+ $body = "<option value=\"\">{$blank}</option>";
foreach ($opts as $opt) {
$sel = selected($selected, $opt[0], false);
$body .= "<option value=\"{$opt[0]}\"{$sel}>{$opt[1]}</option>";