2

我有一个带有文本框的简单表单进行搜索,我希望它的工作方式类似于自动完成。当用户键入时,我希望它将结果返回到表中。

例子

目前,我有

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

我有一个函数可以在转到 admin/store/coupons/autocomplete/product 时返回结果,所以这不是问题。我知道如何得到我想要的结果。我只希望它们显示在表格中,而不是像这样:

在此处输入图像描述

我正在使用 Drupal 6。

编辑:我想我需要使用 Drupal 的 AHAH 功能?这是我到目前为止所拥有的:

  $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>',
  );

回调函数是:

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

我将消息输入 div,但我不确定如何获取其中文本框的值。它只是显示TEST AHAH

4

0 回答 0