# used for selecting a new category to attach this item to. sub _new_category_id_box { my $item = shift; my $name = shift; my $tbl = $Cascade::DBH->selectall_arrayref(" SELECT id, name, (length(sort_key)-2) as level FROM category ORDER BY sort_key"); my %parents; my $q = new CGI; my @p_ids; foreach my $row (@$tbl) { my ($id,$name,$level) = @$row; $parents{$id} = ' 'x$level.CGI::escapeHTML($name); push @p_ids, $id; # we keep the ids in a seperate array to preserve sorting } $q->autoEscape(undef); # we need to turn this off for the spaces in the list to show up correctly. return $q->scrolling_list( -name=>$name, -values=>[@p_ids], -labels=>\%parents, -default=>$item->category_id, -multiple=>0, -size=>1, ); }