app-verk / redactor-bundle
AppVerk redactor bundle
2.0
2018-06-18 10:38 UTC
Requires
- php: ^7.0
This package is auto-updated.
Last update: 2024-09-23 01:16:24 UTC
README
Symfony Redactor Bundle。此扩展包是运行 redactor.js 脚本所必需的。
配置
使用 composer 需要此扩展包
$ composer require app-verk/redactor-bundle
在内核中启用此扩展包
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new AppVerk\RedactorBundle\RedactorBundle(),
// ...
);
}
添加到 config.yml
twig:
form:
resources:
- 'RedactorBundle:Redactor:fields.html.twig'
redactor:
basic:
settings:
lang: 'en'
minHeight: 300
将这些库添加到您的布局中
<!--css -->
<link rel="stylesheet" href="{{ asset('/your-folder/redactor.css') }}" />
<!-- js -->
<script src="{{ asset('/your-folder/redactor.js') }}"></script>
<script src="{{ asset('bundles/redactor/js/symfony-script.js') }}"></script>
Redactor 表单类型
<?php
use Symfony\Component\Form\AbstractType;
use AppVerk\RedactorBundle\Form\Type\RedactorType;
use Symfony\Component\Form\FormBuilderInterface;
class Post extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$formMapper
->add('body', RedactorType::class, [
'redactor' => 'basic' // your config name
])
;
}
}
许可证
此扩展包在 MIT 许可证 下发布。