0

私のアプリケーションでは、検索入力でオートコンプリートを作成しました。データベースからデータを返すと、'"searchForm":{}' という名前の追加していない配列に追加のキーが追加されます。

<li>この追加のキーにより、オートコンプリート メニューが空になります

私の行動:

 public function autocompleteAction()
    {
        $term     = $this->params()->fromQuery('term');     
        $results  = $this->getWebsiteTable()->searchSites($term, 6);

        foreach ($results as $website)
        {
            $data[] = array('label' => $website->hostname);
        }

        $json = new JsonModel($data);
        return $json;
    }

JSON 出力:

{
    "0": {
        "label": "tumblr.com"
    },
    "1": {
        "label": "tumbleweedtreasures.etsy.com"
    },
    "2": {
        "label": "tumblrenchantment.googlecode.com"
    },
    "3": {
        "label": "tumblring.net"
    },
    "4": {
        "label": "tumbleweedhouses.com"
    },
    "5": {
        "label": "tumblebooks.com"
    },
    "searchForm": {}
}

このsearchForm鍵はどこから来ているのですか?どうすれば削除できますか?

4

1 に答える 1

0

アプリケーションモジュールに静的検索フォームを設定しているため、おそらくこのsearchFormをajaxモジュールaswelに含めようとしました。アプリケーション モジュールから searchForm を削除し、必要な特定のモジュールに設定しました。

于 2013-06-01T07:36:38.483 に答える