Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [regert] enum or set fields as html selects

Quote Reply
Re: [regert] enum or set fields as html selects In reply to
Have you set your form types, form names, and form values in your table properties? If so, you can use the default template set and form generation routines to display those enum/set values in the desired format. For a custom template you'll want to use <%Dbsql::HTML::generate_checkbox('column_name')%> or the equivalent for radio, select, etc.

Or, for display purposes with a custom template, you could use the following global (thanks to TheStone for the code):

Code:
sub {
# Maps form_names to form_values and displays them
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
my $record = $tags->{results}[$tags->{row_num} - 1];
my $values = $cols->{$col}->{'form_values'};
my $names = $cols->{$col}->{'form_names'};
my @selected = split(/\n/, $record->{$col});
my (%hash, $output);
for (0 .. $#{$names}) {
$hash{$names->[$_]} = $values->[$_];
}
foreach ( @selected ) {
$output .= "$hash{$_}<br />" if ( $hash{$_} );
}
return "$output";
}

To get that to work, you would just reference the column name as the parameter for the subroutine, as in <%globalname('columnname')%>.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund

Last edited by:

hennagaijin: Jan 24, 2003, 3:22 PM
Subject Author Views Date
Thread enum or set fields as html selects regert 3613 Jan 24, 2003, 1:08 PM
Thread Re: [regert] enum or set fields as html selects
hennagaijin 3501 Jan 24, 2003, 2:49 PM
Post Re: [hennagaijin] enum or set fields as html selects
regert 3485 Jan 24, 2003, 11:02 PM