2

有谁知道是否有奏鸣曲小部件可以在编辑表单中显示 HTML 编辑器?我正在考虑为该字段使用集成了 HTML 的自定义模板,但我想知道是否有更好的方法。

4

4 回答 4

3

试试IvoryCKEditorBundle

于 2012-02-14T10:14:38.320 回答
1

SonataFormatterBundle

于 2015-06-26T06:41:33.717 回答
0

我还使用了 IvoryCKEditorBundle

在您的项目中进行初始设置后,您可以轻松地使用它,如下所示:

use Ivory\CKEditorBundle\Form\Type\CKEditorType;

protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
           ->add('description', CKEditorType::class)
于 2016-12-03T06:45:50.600 回答
0

这是你如何实现它:https ://sonata-project.org/bundles/formatter/master/doc/reference/formatter_widget.html

我的代码示例:

source_field -> body => existing entity field
format_field -> formattedBody => create new field in entity
target_field -> body => existing entity field

protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('body', 'sonata_formatter_type', array(
'event_dispatcher' =>
     $formMapper->getFormBuilder()->getEventDispatcher(),
'format_field' => 'formattedBody',
'format_field_options' => array(
    'choices' => array('richhtml'),
    'data' => 'richhtml',
),
'source_field' => 'body',
'source_field_options' => array(
    'attr' => array(
        'class' => 'span10',
        'rows' => 20,
    ),
),
'listener' => true,
'target_field' => 'body',
))
于 2017-05-08T10:41:10.513 回答