Increased Functionality for the "selection" field

the_exa_boy - July 2, 2007 - 14:57
Project:Profile CSV
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:the_exa_boy
Status:active
Description

I was wanting to assign different values to both the key and value for a select OPTION. i have modified 3 lines of code to achieve this in the profile.module.

Here is the complete section of affected code.

case 'selection':
        $options = $field->required ? array() : array('--');
        $lines = split("[,\n\r]", $field->options);       
        foreach ($lines as $line) {
          if ($line = trim($line)) {
          $key = $value = $line;
          if (strpos($line, '=>') !== FALSE) {
            list($key, $value) = explode("=>", $line);            
          }         
            $options[$key] = $value;
          }
         
        }
        $fields[$category][$field->name] = array('#type' => 'select',
          '#title' => check_plain($field->title),
          '#default_value' => $edit[$field->name],
          '#options' => $options,
          '#description' => _profile_form_explanation($field),
          '#required' => $field->required,
        );
        break;

#1

the_exa_boy - July 2, 2007 - 14:58

// $Id: profile.module,v 1.186 2006/12/27 12:55:52 dries Exp $

very sorry, the code segment starts at 670.

 
 

Drupal is a registered trademark of Dries Buytaert.