0

I have a Drupal 6 site that runs Apache Solr. I need to programmatically add a search form to a custom block that is created by code.

Here is what I'm using:

  $form = array();

  $form['#action'] = 'sitesearch/';

  // search form
  $form['keys'] = array(
    '#title' => NULL,
    '#type' => 'textfield',
    '#value' => t('Search for questions and answers'),
  );

  // add in the click in erase routine
  $form['keys']['#attributes'] = array(
    'class' => 'NormalTextBox txtSearch', 
    'onblur' => "if (this.value == '') {this.value = '" . $form['keys']['#value'] . "';} ;",
    'onfocus' => "if (this.value == '" . $form['keys']['#value'] . "') {this.value = '';} ;"
  );

  $form['submit'] = array(
    '#value' => t('Search'),
    '#type' => 'submit',
    '#attributes' => array('class' => 'filtered-search-form-submit'),
  );

  return $form;

When I submit the form I get to the search results page but it's blank, as if nothing was searched. Any ideas or guidance would be great.

2
  • Which search function are you using? Where is the url sitesearch/ pointing to? – Vivek Feb 24 '12 at 7:39
  • Apache Solr, search results page. – Justin Feb 24 '12 at 21:55
0

I'm pretty brain-dead. I just set up a custom submit handler for a custom form for search to redirect after form submission to the search results page with the right URL, e.g., passing the query and filter in manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.