Gossamer Forum
Home : Products : DBMan SQL : Discussion :

enum or set fields as html selects

Quote Reply
enum or set fields as html selects
Is there a way to get DBManSQL to present the items in an enum or set field in the db as a select/radio/checkbox html field when using the add or modify forms ?

It seems that the default behavior is to just present a blank box.

Thanks

Bob
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
Quote Reply
Re: [hennagaijin] enum or set fields as html selects In reply to
Thank you.

I hadn't set up the form names and form values correctly

Worked fine after I did.

Bob