I added the following code to get a select box in the registration form:

Convert to string to a form array
Line 448: Before:

foreach ($data as $pair) {
  list($k, $v) = explode('=>', $pair);
  $field += array('#'. trim($k) => trim($v));
}

Line 448: After:

foreach ($data as $pair) {
  list($k, $v) = explode('=>', $pair);
  if(trim($k) == 'options') {
    $_options = (Array) explode(",", $v);
    foreach($_options as $option) 
      $options[trim($option)] = trim($option);
    $field += array('#'. trim($k) => $options);
  }
  else	
    $field += array('#'. trim($k) => trim($v));
}

Convert form array to a string
Line 175: Before:

array_walk($data, create_function('&$v, $k', '$v = drupal_substr($k, 1) .\'=>\'. $v;'));

Line 175: After:

array_walk($data, create_function('&$v, $k', 'if(is_array($v)) $v = implode(",",$v); $v = drupal_substr($k, 1) .\'=>\'. $v;'));

By adding "options=>option1,option2" to the field properties you will populate the select box.

selectattribute|type=>select|title=>Select Box|required=>1|description=>Pick one of the following options.|options=>Option1,Option2

Comments

Nr. 18’s picture

The $options array should be cleaned for every element

$options = array();
$_options = (Array) explode(",", $v);
foreach($_options as $option)
$options[trim($option)] = trim($option);

madhusudan’s picture

@Nr. 18 , Thanks for the code,
well I tried this code, but works for only one select box, if I try to add another select box,it shows up as empty box!.

and if i give options=>Option1,Option2 for second select box in Custom elements, its adding up the previous
options+new options.

any solution for this..