Hi there, I'm having a huge fight with a view I'm theming. I have a custom view function that is getting two values: nid and title. I'm dumping them into an associative array and want each item to show up in a jump menu.

$options = array();
  
  foreach( $rows as $row ) {
    $nids = split('-',$row);
    $options[$nids[0]] = substr($nids[1], 35, -1);  // Trim off the "What can I do with a degree in?"
  }

  $form['#id'] = 'jumpmenu-'.$view_name; // give it a unique name, in case you want to have more than one on a page
  $form['#attributes'] = array('class' => 'jumpmenu-form', 'name' => 'jumpmenu-'.$view_name ); // again - for uniqueness and styling
  $form['nid-'.$view_name] = array(
    '#type' => 'select',
    '#options' => $options,
    '#id' => 'edit-nid-' . $view_name,
    '#class' => 'jumpmenu-item',
  );

But then the box shows up with just the text "Array" - it's not populated.

A print of the $options array reveals that it is there, and correct:

Array([12] => Title, [14] => Next title)

I've tried putting it in manually -

#options => array('1' => 'Title', '2' => 'Next title'),

but no dice.

So... er... What the heck am I doing wrong??

Comments

Renee S’s picture

Fixed it, required changing #id and #class to be #attributes.