From 88054e0ab0837f09cfc740369d6469e9816a3d6c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 12 Jan 2009 22:16:00 -0500 Subject: [PATCH] Required custom select fields will no longer show the empty option. This is only a UI change, though, as these empty options would not validate. * includes/functions.php: (construct_custom_fields): Required select fields do not get a blank option --- docs/changes.txt | 1 + includes/functions.php | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3fae91d..86a01c1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -3,6 +3,7 @@ - Fixed: #121: Custom select field that is mandatory doesn't accept the first option as a valid entry - Fixed: Improved XHTML compliance in various templates - Fixed: #134: Column headers (defined in includes/definitions.php) were not marked with T() for translation +- Change: Required custom select fields will no longer show the empty option (these fields could not be saved as empty, though, because they wouldn't validate -- this is purely an interface change) 1.2.2 =============================== diff --git a/includes/functions.php b/includes/functions.php index 06441db..efc477a 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -277,17 +277,23 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau $options = ''; - $id = -1; - $select = ''; - if (!$field['usedefault'] AND !trim($value)) + // this overrides $field['usedefault'] because required fields will no longer have + // blank values as options + // TODO document above comment in the ACP + if (!$field['required']) { - $selected = ' selected="selected"'; - } - else - { - $selected = ''; + $id = -1; + $select = ''; + if (!$field['usedefault'] && !trim($value)) + { + $selected = ' selected="selected"'; + } + else + { + $selected = ''; + } + eval('$options .= "' . $bugsys->template->fetch('bugfield_select_single_option') . '";'); } - eval('$options .= "' . $bugsys->template->fetch('bugfield_select_single_option') . '";'); foreach ($selects AS $id => $select) { -- 2.43.5