brookinsconsulting / bcknockoutjsbundle
Symfony BcKnockoutJSBundle
dev-master
2017-02-24 07:37 UTC
Requires
- php: >=5.6.0
- jms/di-extra-bundle: ^1.8
- symfony/symfony: 3.2.*
This package is auto-updated.
Last update: 2024-09-29 04:48:45 UTC
README
将 knockout.js 集成到 Symfony2,提供集合的自动代码生成。
1. 示例
$builder
->add('items', 'knockout', array(
'type' => new OrderItemType(),
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'by_reference' => false,
))
;
我已添加了具有 KnockoutType 的 items 字段,它继承自 CollectionType,并按集合方式处理。
2. 安装
2.1. Composer
"brookinsconsulting/bcknockoutjsbundle": "dev-master",
2.2. AppKernel
$bundles = array(
...
new BrookinsConsulting\BcKnockoutJSBundle\BcKnockoutJSBundle(),
);
2.3. config.yml
imports:
...
- { resource: "@BcKnockoutJSBundle/Resources/config/config.yml" }
# BcKnockoutJS Bundle Configuration
jms_di_extra:
locations:
all_bundles: false
bundles: [BcKnockoutJSBundle]
directories: ["%kernel.root_dir%/../src"]
如果你已将 all_bundles 设置为 true,则不需要 jms_di_extra 配置,这是出于性能考虑而被相关上游依赖包强烈不建议的。
2.4. 将 js 添加到你的页面中。
<script src="{{ asset('bundles/bcknockoutjs/js/knockout-3.4.1.js') }}"></script>
2.5. 创建你的视图
{{ knockout(form.vars.knockout)|raw }}
{{ form_widget(form) }}
3. 依赖项
该包确实依赖于 'jms/di-extra-bundle' 包。
为了测试目的,原始作者使用了现在已私有化的 BaseBundle,如果你想测试它,你也需要将其包含在你的 composer.json 文件中。
4. 需要完成的任务
- 生成器。目前命令已存在,但尚未正确工作。