forked from science-ation/science-ation
Add option group support, and as a test implement it for awards report.
It would be nice to remove the "Award -- " off the front of each field name, but if we do that it only displays "Name" after its' selected, which can be confusing if there's an "Award -- Name" and a "Prize -- Name". But the division into optgroups still look nice.
This commit is contained in:
parent
c1433e8a7d
commit
6e245a4c52
@ -23,6 +23,7 @@
|
||||
|
||||
$report_awards_fields = array(
|
||||
'name' => array(
|
||||
'start_option_group' => 'Award Information',
|
||||
'name' => 'Award -- Name',
|
||||
'header' => 'Award Name',
|
||||
'width' => 3.0,
|
||||
@ -60,6 +61,7 @@ $report_awards_fields = array(
|
||||
'table' => 'award_types.type' ),
|
||||
|
||||
'sponsor_organization' => array(
|
||||
'start_option_group' => 'Sponsor Information',
|
||||
'name' => 'Sponsor -- Organization',
|
||||
'header' => 'Sponsor Organization',
|
||||
'width' => 2.0,
|
||||
@ -115,6 +117,7 @@ $report_awards_fields = array(
|
||||
'value_map' => array ('pending' => 'Pending', 'confirmed' => 'Confirmed'), "received"=>"Received"),
|
||||
|
||||
'pcontact_salutation' => array(
|
||||
'start_option_group' => 'Sponsor Primary Contact',
|
||||
'name' => 'Primary Contact -- Salutation',
|
||||
'header' => 'Cnct. Salutation',
|
||||
'width' => 1.0,
|
||||
@ -189,6 +192,7 @@ $report_awards_fields = array(
|
||||
'table' => 'PRIMARYCONTACT.notes' ),
|
||||
|
||||
'judgeteamname' => array(
|
||||
'start_option_group' => 'Judging Team',
|
||||
'components' => array('judgingteam'),
|
||||
'name' => 'Judging Team -- Name',
|
||||
'header' => 'Judging Team',
|
||||
|
@ -44,13 +44,19 @@
|
||||
function field_selector($name, $id, $selected)
|
||||
{
|
||||
global $fields;
|
||||
$in_optgroup = false;
|
||||
echo "<select name=\"$name\" id=\"$id\">";
|
||||
echo "<option value=\"\" />-- None --</option>";
|
||||
foreach($fields as $k=>$f) {
|
||||
if($f['editor_disabled'] == true) continue;
|
||||
if(array_key_exists('start_option_group', $f)) {
|
||||
if($in_optgroup) echo '</optgroup>';
|
||||
echo '<optgroup label="'.i18n($f['start_option_group']).'">';
|
||||
}
|
||||
$sel = ($selected == $k) ? 'selected=\"selected\"': '' ;
|
||||
echo "<option value=\"$k\" $sel >{$f['name']}</option>";
|
||||
}
|
||||
if($in_optgroup) echo '</optgroup>';
|
||||
echo "</select>";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user