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.
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
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)
{