Version 1 (modified by Fran Boon, 14 years ago) ( diff )



Want to be able to sort a Dropdown alphabetically to make it easier for data entry e.g. the Organisations dropdown in 'Add Office'

We have 2 sorts of dropdowns:

  • Database
  • Dictionary

This one is a Database one using the IS_ONE_OF() custom validator from modules/validators.pty

js list sorter:

As far as sorting right in the backend is concerned - models/ line 107, tried putting .select(orderby =[0]... But that did not work out...

Q: If its possible to put a javascript fix where does one put a page specific js ?
A: views/module/resource_method.html

For Dictionary-based ones:

In  models/ change:

or_organisation_type_opts = {
   2:T('International Governmental Organization'),
   3:T('International NGO'),
   5:T('National Institution'),
   6:T('National NGO'),
   7:T('United Nations')
db[table].type.requires = IS_NULL_OR(IS_IN_SET(or_organisation_type_opts))


or_organisation_type_opts = [
   (2,T('International Governmental Organization')),
   (3,T('International NGO')),
   (5,T('National Institution')),
   (6,T('National NGO')),
   (7,T('United Nations'))
db[table].type.requires = IS_NULL_OR(IS_IN_SET(
   [x[0] for x in or_organisation_type_opts],
   [x[1] for x in or_organisation_type_opts]))
Note: See TracWiki for help on using the wiki.