added: ThingyRecord allows you to sell records in a Thing (like a classified ad)

This commit is contained in:
Doug Bell 2009-04-19 02:09:34 +00:00
parent 724675c71c
commit 6d20e7f5df
12 changed files with 1014 additions and 8 deletions

View file

@ -165,13 +165,28 @@ sub toHtml {
my $output = '<select name="'.($self->get("name")||'').'" size="'.($self->get("size")||'').'" id="'.($self->get('id')||'').'" '.($self->get("extras")||'').'>';
my $options = $self->getOptions;
my $value = $self->getOriginalValue();
foreach my $key (keys %{$options}) {
$output .= '<option value="'.$key.'"';
if ($value eq $key) {
$output .= ' selected="selected"';
}
$output .= '>'.$options->{$key}.'</option>';
}
# Recurse for <optgroups>
my $buildOptionsHtml;
$buildOptionsHtml = sub {
my $options = shift;
foreach my $key (keys %{$options}) {
if ( ref $options->{$key} eq 'HASH' ) {
$output .= qq{<optgroup label="$key">};
$buildOptionsHtml->($options->{$key});
$output .= qq{</optgroup>};
}
else {
$output .= '<option value="'.$key.'"';
if ($value eq $key) {
$output .= ' selected="selected"';
}
$output .= '>'.$options->{$key}.'</option>';
}
}
};
$buildOptionsHtml->($options);
$output .= '</select>'."\n";
return $output;
}