Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [Andy] Dynamically generate a drop-down field for a field...: Edit Log

Here is the list of edits for this post
Re: [Andy] Dynamically generate a drop-down field for a field...
Andy:

You're right! I added some comments before the 'sub'.

I also note that your global above pulls out 'all' values from the table, even though those that aren't listed in the Admin Panel. This global will only select those that have been entered into Admin and will also sort them. I found this elsewhere in the Forum - it is not my work...

Code:
sub {

my $column = shift;
my $selected = shift;
my $table = $DB->table("Links");
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
return $form;
}

To call:

<%global_name('ColumnName',$ColumnName)%>



Thanks,


Clint.
--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory

Last edited by:

Clint: Apr 24, 2005, 6:06 PM

Edit Log: