ioalessio/autosuggestbundle
Composer 安装命令:
composer require ioalessio/autosuggestbundle
包简介
Autosuggest widget for Symfony2 Form
README 文档
README
Add IoAutosuggestBundle in your composer.json:
{ "require": { "ioalessio/autosuggestbundle": "dev-master" } }
Now tell composer to download the bundle by running the command:
$ php composer.phar update
Composer will install the bundle to your project's vendor/ioalessio directory.
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Io\AutosuggestBundle\IoAutosuggestBundle(), ); }
Step 3: Configure the bundle
Add javascript files in your page (you can also put at the end of page)
- libs/boostrap/bootstrap-typehead.js
- bundles/ioautosuggest/twitter-bootstrap-typeahead.js #this file extends original twitter bootstrap typehead file
- bundles/ioautosuggest/autosuggest.js
IMPORTANT: bootstrap-typehead.js can be downloaded here: http://twitter.github.com/bootstrap/javascript.html#typeahead
Add widget code in your form template file
{# fields.html.twig #} {% extends 'form_div_layout.html.twig' %} {% block autosuggest_selector_widget %} {% spaceless %} {{ form_widget(form.autosuggest, { 'attr' : { 'class': 'ajax-typeahead ', 'data-value': form.value.vars['id'], 'data-link' : form.vars['attr']['url'] } } ) }} {{ form_widget(form.value) }} {{ form_rest(form) }} {% endspaceless %} {% endblock autosuggest_selector_widget %}
Step 3: Include widget in a Form
#FORM CLASS public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('field', 'autosuggest_selector', array( 'entityName' => 'Acme\DemoBundle\Entity\MyEntity', 'autocompleteMethod' => 'autocomplete', 'valueMethod' => 'id', 'route' => 'autosuggest_typehead' )); ... } #AUTOCOMPLETE CONTROLLER /** * @Route("/autosuggest.{_format}", name="autosuggest_typehead", defaults={"_format"="json"}) */ public function autosuggestAction() { $query = $this->getRequest()->get('query'); $data = $this->getDoctrine()->getEntityManager()->createQuery("SELECT e.id, e.name AS name FROM AcmeDemoBundle:MyEntity e WHERE e.name LIKE :query") ->setParameter('query', "%".$query."%") ->getArrayResult(); // array must countain 'id' and 'name' $response = new Response(json_encode($data)); return $response; }
ioalessio/autosuggestbundle 适用场景与选型建议
ioalessio/autosuggestbundle 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 982 次下载、GitHub Stars 达 0, 最近一次更新时间为 2013 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「autocomplete」 「autosuggest」 「Symfony2 Form」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ioalessio/autosuggestbundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ioalessio/autosuggestbundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ioalessio/autosuggestbundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Cassandra php driver library IDE stubs which enables autocompletion in modern IDEs.
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Dadata API client (https://dadata.ru)
Yii2 Jui AutoComplete with Id field widget
Symfony2 Barcode Generator Bundle with Twig function extension
Symfony bundle to connect AWS sns and sqs to create offline queue processing
统计信息
- 总下载量: 982
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL
- 更新时间: 2013-02-06