Search code examples
ckeditorplaceholdersymfony

Symfony | CKEditor placeholder


I'm using IvoryCKEditorBundle (http://symfony.com/doc/master/bundles/IvoryCKEditorBundle/index.html)

I can't find a way to add a placeholder in buildform configuration. This is not working :

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

How can I do this ? I have to do it in JQuery ?

TY


Solution

  • You need a CKEditor plugin to do that.

    Download the Configuration Helper plugin from http://ckeditor.com/addon/confighelper and extract the folder from the zip file to the web bundles directory of your app (web/bundles/confighelper/).

    Load the plugin in your buildForm method and set the placeholder as follows

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