【问题标题】:Symfony | CKEditor placeholderSymfony | CKEditor 占位符
【发布时间】:2023-04-06 06:06:01
【问题描述】:

我正在使用 IvoryCKEditorBundle (http://symfony.com/doc/master/bundles/IvoryCKEditorBundle/index.html)

我找不到在 buildform 配置中添加占位符的方法。 这不起作用:

->add('text', CKEditorType::class, array(
            'attr' => array(
                'placeholder' => 'Your text ...'
            )
        ))

我该怎么做?我必须在 JQuery 中完成?

TY

【问题讨论】:

  • 可以试试用'placeholder' => 'Your text ...' 直接同级attr吗?
  • 如果我在同级别的attr中使用“占位符”选项不存在

标签: ckeditor placeholder symfony


【解决方案1】:

你需要一个 CKEditor 插件来做到这一点。

http://ckeditor.com/addon/confighelper 下载 Configuration Helper 插件,然后将文件夹从 zip 文件解压缩到应用程序的 Web 包目录 (web/bundles/confighelper/)。

在你的buildForm方法中加载插件并设置占位符如下

->add('text', CKEditorType::class, array(
    'config' => array(
        'extraPlugins' => 'confighelper',
        'placeholder' => 'Your text ...',
    ),
    'plugins' => array(
        'confighelper' => array(
            'path' => '/bundles/confighelper/',
            'filename' => 'plugin.js',
        ),
    )
))

【讨论】:

    【解决方案2】:

    我不知道这是否曾经是最好的方法,但目前正确的答案是:

    ->add('text', CKEditorType::class, array(
                    'config' => array(
                        'editorplaceholder' => 'placeholder text...',
                    ),
                ))
    

    【讨论】:

      猜你喜欢
      • 2018-02-23
      • 2018-03-19
      • 1970-01-01
      • 2014-11-04
      • 2017-10-25
      • 2019-03-27
      • 2015-06-29
      • 2015-08-15
      • 2023-04-10
      相关资源
      最近更新 更多