xoops forums

sarahmx

Quite a regular
Posted on: 2012/11/6 18:55
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 371
Since: 2007/10/28
#1

how do is sort select boxes alphabetically in profile module ?



is this possible how ?

sarahmx

Quite a regular
Posted on: 3/7 22:09
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 371
Since: 2007/10/28
#2

Re: how do is sort select boxes alphabetically in profile module ?

Bumping 6 year old thread

Resized Image

anyone ? How do i sort the select box created using the profile module

sarahmx

Quite a regular
Posted on: 3/8 6:37
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 371
Since: 2007/10/28
#3

Re: how do is sort select boxes alphabetically in profile module ?

i saw this code in modules/profile/class/field.php
case 'select':
                
$element = new XoopsFormSelect($caption$name$value);
                
// If options do not include an empty element, then add a blank option to prevent any default selection
//                if (!in_array('', array_keys($options))) {
                
if (!array_key_exists(''$options)) {
                    
$element->addOption(''_NONE);

                    
$eltmsg                          = empty($caption) ? sprintf(_FORM_ENTER$name) : sprintf(_FORM_ENTER$caption);
                    
$eltmsg                          str_replace('"''"'stripslashes($eltmsg));
                    
$element->customValidationCode[] = "nvar hasSelected = false; var selectBox = myform.{$name};" "for (i = 0; i < selectBox.options.length; i++) { if (selectBox.options[i].selected == true && selectBox.options[i].value != '') { hasSelected = true; break; } }" "if (!hasSelected) { window.alert("{$eltmsg}"); selectBox.focus(); return false; }";
                }
                
$element->addOptionArray($options);
            
                break;


what do i need to change ?

trabis

Core Developer
Posted on: 3/9 5:50
trabis
trabis (Show more)
Core Developer
Posts: 2258
Since: 2006/9/1 1
#4

Re: how do is sort select boxes alphabetically in profile module ?

Try
case 'select':
    
asort($options);

sarahmx

Quite a regular
Posted on: 3/10 10:05
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 371
Since: 2007/10/28
#5

Re: how do is sort select boxes alphabetically in profile module ?

Thank you trabis..its working