From 660c75f6107f124837f2ab86b69df2ebd6938a9a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 13 Jan 2009 12:26:09 -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. * docs/changes.txt: Merged * includes/functions.php: (construct_custom_fields): Required select fields do not get a blank option * templates/bugfield_select_single.tpl: Need to convert to BSTemplate * templates/bugfield_select_single_option.tpl: ditto Cherry-pick 88054e0ab0837f09cfc740369d6469e9816a3d6c --- docs/changes.txt | 5 ++++- includes/functions.php | 21 ++++++++++++++------- templates/bugfield_select_single.tpl | 2 +- templates/bugfield_select_single_option.tpl | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 22ae6ab..977beb5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -4,7 +4,10 @@ 1.2.3 =============================== -- Fixed: Custom select field that is mandatory doesn't accept the first option as a valid entry (bug://report/121) +- 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 3971261..38cdf84 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -290,14 +290,21 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau case 'select_single': $selects = unserialize($field['selects']); $value = trim($value); + $options = ''; - $tpl = new BSTemplate('bugfield_select_single_option'); - $tpl->vars = array( - 'id' => -1, - 'select' => '', - 'selected' => ((!$field['usedefault'] && !trim($value)) ? ' selected="selected"' : '') - ); - $options = $tpl->evaluate()->getTemplate(); + // 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']) + { + $tpl = new BSTemplate('bugfield_select_single_option'); + $tpl->vars = array( + 'id' => -1, + 'select' => '', + 'selected' => ((!$field['usedefault'] && !trim($value)) ? ' selected="selected"' : '') + ); + $options = $tpl->evaluate()->getTemplate(); + } foreach ($selects as $id => $select) { diff --git a/templates/bugfield_select_single.tpl b/templates/bugfield_select_single.tpl index bf3048f..1b0a8c8 100644 --- a/templates/bugfield_select_single.tpl +++ b/templates/bugfield_select_single.tpl @@ -1,6 +1,6 @@
- <%- $field['name'] %> <%- $help['field' . $field['fieldid']] %> + <%- $field['name'] %> help[field<%- $field['fieldid'] %>]
\ No newline at end of file diff --git a/templates/bugfield_select_single_option.tpl b/templates/bugfield_select_single_option.tpl index aaa9591..d4ab283 100644 --- a/templates/bugfield_select_single_option.tpl +++ b/templates/bugfield_select_single_option.tpl @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file -- 2.43.5