HI, all.
I want change textfield in form add nodequeue:

 $form['add']['nid'] = array(
    '#type' => 'select',
    '#autocomplete_path' => 'nodequeue/autocomplete/'. $subqueue->sqid,
    '#default_value' => 'Enter the title of a node to add it to the queue',
  );

to

  $sql = db_query_range('SELECT nid, title FROM {node} WHERE 1 ORDER BY created', 0 , 30);
  $option = array();
   while ($db = db_fetch_object($sql)) {
	$option[$db->nid] = $db->title;
}	
  $form['add']['nid'] = array(
    '#type' => 'select',
   // '#autocomplete_path' => 'nodequeue/autocomplete/'. $subqueue->sqid,
	'#options' => $option,
    '#default_value' => 'Enter the title of a node to add it to the queue',
  );

but when i add to node queue not work

Comments

cuxi’s picture

hi. i have code function submit to

function nodequeue_arrange_subqueue_form_add_submit($form, &$form_state) {
  $queue = nodequeue_load($form['#queue']['qid']);
  $subqueue = nodequeue_load_subqueue($form['#subqueue']['sqid']);
  if (!empty($form_state['values']['add']['nid'])) {
    preg_match('/\[nid: (\d+)\]$/', $form_state['values']['add']['nid'], $matches);
   // $nid = $matches[1];
   $nid = $form_state['values']['add']['nid'];
    if (empty($nid)) {
      form_set_error('', t('Please enter a valid node title.'));
    }
  }

  nodequeue_subqueue_add($queue, $subqueue, $nid);
}

now it's works

ezra-g’s picture

Status: Active » Fixed

Sounds like you figured this out. Marking as fixed :)!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

andersthorborg’s picture

Version: 6.x-2.5 » 7.x-2.0-alpha2

I implemented this feature to work with D7. I'm a drupal newbie, and I don't know how to create a patch. However this solved my needs:

Replace

<?php
$form['add']['nid'] = array(
    '#type' => 'textfield',
    '#autocomplete_path' => 'nodequeue/autocomplete/' . $subqueue->sqid,
    '#maxlength' => 1024,
    '#default_value' => t('Enter the title of a node to add it to the queue'),
  );
?>

with

<?php
  /** Limit query to specified types **/
  $whereTypes = array();  
  if($queue->types && count($queue->types) > 0){
      foreach($queue->types as $type){
          $whereTypes[] = 'type = \'' . $type . '\'';
      }
  }
  $whereTypes = implode(' OR ', $whereTypes);  
  
  /** Limit query to nodes not already added to the queue **/
  $whereNodes = array();
  foreach($nodes as $node){
      $whereNodes[] = 'nid != \'' . $node->nid . '\'';
  }
  $whereNodes = implode(' AND ', $whereNodes); 
  
  /** Fetch db-data **/
  $result = db_query('SELECT nid, title FROM {node} WHERE (' . $whereTypes . ') AND (' . $whereNodes . ') ORDER BY title');  
  
  /** Generate options array **/
  $options = array(-1 => t('Select a node to add'));  
  foreach($result as $res){
    $options[$res->nid] = $res->title;    
  }	
  
  /** Add form element **/
  $form['add']['nid'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => -1
  );
  
  $form['add']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add content'),
    '#submit' => array('nodequeue_arrange_subqueue_form_add_submit'),
  );

?>

And replace the submit function with this:

<?php

function nodequeue_arrange_subqueue_form_add_submit($form, &$form_state) {
  $queue = nodequeue_load($form['nodes']['#queue']['qid']);
  $subqueue = nodequeue_load_subqueue($form['nodes']['#subqueue']['sqid']);  
  if (!empty($form_state['values']['add']['nid']) && $form_state['values']['add']['nid'] != -1) {
    $nid = $form_state['values']['add']['nid'];            
    nodequeue_subqueue_add($queue, $subqueue, $nid);       
  }
  else{    
    form_set_error('', t('Please select a node.'));    
  }  
}

?>

Feel free to tighten it up - this works for me with 7.x-2.0-alpha2.