Skip Menu |

This queue is for tickets about the Class-DBI-FormBuilder CPAN distribution.

Report information
The Basics
Id: 14652
Status: resolved
Priority: 0/
Queue: Class-DBI-FormBuilder

People
Owner: Nobody in particular
Requestors: rmcclain [...] megapath.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.451
Fixed in: (no value)



Subject: select lists not sorted
select dropdowns are not sorted. This is a problem for me, as some of my select lists are large and it's impossible to find anything. In sub _field_options right before it returns, I added: @options = sort { $a->[1] <=> $b->[1] } @options;
[guest - Mon Sep 19 18:44:42 2005]: Show quoted text
> select dropdowns are not sorted. This is a problem for me, as some of > my select lists are large and it's impossible to find anything. In > sub _field_options right before it returns, I added: > > @options = sort { $a->[1] <=> $b->[1] } @options; >
This assumes all the labels are numbers. If they're not, you'll get lots of warnings. If you use cmp instead, there'll be no warnings, but if your labels are numbers, they'll come out in weird order ( 1, 11, 111, 12, 2 ...). It's definitely something that needs fixed though. I think there's some way of specifiying a default order in CDBI for retrieving records, but I don't know where to start looking. There also might be an option in CGI-FB. d.
From: rmcclain [...] megapath.net
[DAVEBAIRD - Tue Sep 20 06:28:31 2005]: Show quoted text
> [guest - Mon Sep 19 18:44:42 2005]: >
> > select dropdowns are not sorted. This is a problem for me, as some
> of
> > my select lists are large and it's impossible to find anything.
> In
> > sub _field_options right before it returns, I added: > > > > @options = sort { $a->[1] <=> $b->[1] } @options; > >
> > This assumes all the labels are numbers. If they're not, you'll get > lots > of warnings. If you use cmp instead, there'll be no warnings, but if > your labels are numbers, they'll come out in weird order ( 1, 11, 111, > 12, 2 ...). > > It's definitely something that needs fixed though. I think there's > some > way of specifiying a default order in CDBI for retrieving records, but > I > don't know where to start looking. There also might be an option in > CGI-FB. > > d.
There's a sortopts option in CGI::FB, but it also requires you to specify whether to use text or numeric sorting, so it's not much help. I didn't see anything in Class::DBI about a default sort order, but I'm not sure it would help anyway. Since you'd be sorting by the stringified object, you couldn't use database sorting in a lot of cases (e.g., when using stringify_self). Anyhow, I've patched my own copy of FB to use cmp on the values. Works well enough for me. At least I can find things. Sure, numeric only lists are ugly looking, but oh well.
Date: Mon, 26 Sep 2005 01:12:59 +0100
From: David Baird <dave.riverside [...] gmail.com>
To: bug-Class-DBI-FormBuilder [...] rt.cpan.org
Subject: Re: [cpan #14652] select lists not sorted
RT-Send-Cc:
On 9/22/05, Guest via RT <bug-Class-DBI-FormBuilder@rt.cpan.org> wrote: Show quoted text
> > This message about Class-DBI-FormBuilder was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=14652 > > > [DAVEBAIRD - Tue Sep 20 06:28:31 2005]: >
> > [guest - Mon Sep 19 18:44:42 2005]: > >
> > > select dropdowns are not sorted. This is a problem for me, as some
> > of
> > > my select lists are large and it's impossible to find anything.
> > In
> > > sub _field_options right before it returns, I added: > > > > > > @options = sort { $a->[1] <=> $b->[1] } @options; > > >
> > > > This assumes all the labels are numbers. If they're not, you'll get > > lots > > of warnings. If you use cmp instead, there'll be no warnings, but if > > your labels are numbers, they'll come out in weird order ( 1, 11, 111, > > 12, 2 ...). > > > > It's definitely something that needs fixed though. I think there's > > some > > way of specifiying a default order in CDBI for retrieving records, but > > I > > don't know where to start looking. There also might be an option in > > CGI-FB. > > > > d.
> > > There's a sortopts option in CGI::FB, but it also requires you to > specify whether to use text or numeric sorting, so it's not much help. > I didn't see anything in Class::DBI about a default sort order, but I'm > not sure it would help anyway. Since you'd be sorting by the > stringified object, you couldn't use database sorting in a lot of cases > (e.g., when using stringify_self). Anyhow, I've patched my own copy of > FB to use cmp on the values. Works well enough for me. At least I can > find things. Sure, numeric only lists are ugly looking, but oh well. > >
Gotta sleep, but tomorrow I'll upload the latest, which allows you to provide a hash of coderefs (keyed by field name) to sort these things. The thing I thought I remembered in CDBI turned out to be just for has_many rels. d.