-1

我正在 Zend 中开发一个模块。

用户向数据库添加订单,但必须选择特定用户。

使用通常的选择列表表单会很不舒服,因为管理员必须在数百个用户之间进行选择。

因此,拥有一个在数据库中搜索的 Ajax 表单,然后让管理员为订单选择特定用户,然后使用 user_id 将此订单保存到数据库中,这就是我想要做的。

那么,有什么想法可以实现吗?

4

1 回答 1

2

@ficuscr 提出了一些很棒的建议!肯定需要一些时间来研究这些。

Zend 是一个很棒的可靠的库,它使开发变得快速和容易……但是它非常通用。您尝试做的不是 Zend 特定的,而是它的应用程序特定的。

要实现您想要的,您需要以下内容(请记住,这样做的方法很少):

  • 使用 ID #userSelect 将文本框输入添加到您的订单
  • 添加一些返回 json 数据的 Controller Action ( Zend JSON Helper )

    class FooController extends Zend_Controller_Action
    {
        public function barAction() {
           // do some processing...
           // Send the JSON response:
           $this->_helper->json($data); 
        }
    }
    

  • 将 jQuery 和 jQuery UI 依赖项添加到您的文档中。您可以通过视图助手添加这些,或者简单地将它们添加到您的布局中。

     <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
     <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
     <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    

  • 在文档头部添加 jQuery UI Autocomple 魔法(请参阅 API 文档

    $(document).ready(function() {    
       // you can use absolute url, but relative should work just fine (assuming you dont change your basehref)
       $('#userSelect' ).autocomplete({ source: '/foo/bar' });
    });
    

  • 这就对了...

    于 2012-12-21T01:41:42.923 回答