Add the following subroutines to db.cgi.
Code:
sub build_select_field_2 {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition for use in the multiple modify
# spreadsheet form. Parameters are the column to build,
# default value (optional) and the key value for the record.
my ($column, $value, $key) = @_;
my (@fields, $ouptut);
@fields = split (/\,/, $db_select_fields{$column});
if ($#fields == -1) {
$output = "error building select field: no select fields specified in config for field '$column'!";
}
else {
$output = qq|<SELECT NAME="$key-$column"><OPTION>---|;
foreach $field (@fields) {
$field eq $value ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
}
return $output;
}
sub build_checkbox_field_2 {
# --------------------------------------------------------
# Builds a CHECKBOX field based on information found
# in the database definitionfor use in the multiple modify
# spreadsheet form. Parameters are the column to build,
# default value (optional) and the key value for the record.
my ($column, $values, $key) = @_;
if (!$db_checkbox_fields{$column}) {
return "error building checkboxes: no checkboxes specified in config for field '$column'";
}
my @names = split (/,/, $db_checkbox_fields{$column});
my @values = split (/\Q$db_delim\E/, $values);
my ($name, $output);
foreach $name (@names) {
(grep $_ eq $name, @values) ?
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$key-$column" VALUE="$name" CHECKED> $name\n!) :
($output .= qq!<INPUT TYPE="CHECKBOX" NAME="$key-$column" VALUE="$name"> $name\n!);
}
return $output;
}
sub build_radio_field_2 {
# --------------------------------------------------------
# Builds a RADIO Button field based on information found
# in the database definitionfor use in the multiple modify
# spreadsheet form. Parameters are the column to build,
# default value (optional) and the key value for the record.
my ($column, $value, $key) = @_;
my (@buttons, $button, $output);
@buttons = split (/,/, $db_radio_fields{$column});
if ($#buttons == -1) {
$output = "error building radio buttons: no radio fields specified in config for field '$column'!";
}
else {
foreach $button (@buttons) {
$value =~ /^\Q$button\E$/ ?
($output .= qq|<INPUT TYPE="RADIO" NAME="$key-$column" VALUE="$button" CHECKED> $button \n|) :
($output .= qq|<INPUT TYPE="RADIO" NAME="$key-$column" VALUE="$button"> $button \n|);
}
}
return $output;
}