2

I have a simple form with a textbox to search and I want it to work similar to autocomplete. As the user types, I want it to return results to a table.

example

Currently, I have

$form['search'] = array(
    '#type' => 'textfield',
    '#title' => 'Search',
    '#description' => 'Search by', 
    '#autocomplete_path' => 'admin/store/products/group/autocomplete', 
);

I have a function that returns results when going to admin/store/coupons/autocomplete/product, so that isn't the issue. I know how to get the results I want. I just want them displayed in a table instead of like this:

enter image description here

I'm using Drupal 6.

EDIT: I'm thinking I need to use Drupal's AHAH functionality? Here's what I have so far:

  $form['search'] = array(
    '#type' => 'textfield',
    '#title' => 'Search',
    '#description' => 'Search by',  
    '#ahah' => array(
      'event' => 'change',
      'path' => 'admin/store/products/group/autocomplete',
      'wrapper' => 'products-search-wrapper',
      'method' => 'append',
      'effect' => 'none', 
      'progress' => array(
        'type' => 'throbber', 
        'message' => 'Loading results...',
      ),
    ),  
  );

  $form['search_results'] = array(
    '#type' => 'markup',
    '#value' => '<div id="products-search-wrapper"></div>',
  );

The callback function is:

function tf_cart_admin_group_autocomplete($search)
{
  print drupal_json(array('status' => TRUE, 'data' => "TEST AHAH $search"));
  exit;
}

I am getting the message into the div, but I'm not sure how to get the value of the textbox in there. It is just displaying TEST AHAH

AllisonC
  • 2,973
  • 4
  • 29
  • 46
  • I think you have to write javascript code to parse #autocomplete div and get results to build table. Otherwise , use custom field with custom ajax instead of core autocomplete – Fky Aug 16 '17 at 07:15

0 Answers0