Skip to content

Style support

Edit this page

The bundle allows you to define your own styles. Like plugins, you can define them globally in your configuration:

1
2
3
4
5
6
7
8
9
10
11
# app/config/config.yml
fos_ck_editor:
    default_config: my_config
    configs:
        my_config:
            stylesSet: "my_styles"
    styles:
        my_styles:
            - { name: "Blue Title", element: "h2", styles: { color: "Blue" }}
            - { name: "CSS Style", element: "span", attributes: { class: "my_style" }}
            - { name: "Widget Style", type: widget, widget: "my_widget", attributes: { class: "my_widget_style" }}

Or you can define them in your widget:

1
2
3
4
5
6
7
8
9
10
11
12
13
$builder->add('field', 'ckeditor', [
    'config' => [
        'stylesSet' => 'my_styles',
    ],
    'styles' => [
        'my_styles' => [
            ['name' => 'Blue Title', 'element' => 'h2', 'styles' => ['color' => 'Blue']],
            ['name' => 'CSS Style', 'element' => 'span', 'attributes' => ['class' => 'my_style']],
            ['name' => 'Multiple Element Style', 'element' => ['h2', 'span'], 'attributes' => ['class' => 'my_class']],
            ['name' => 'Widget Style', 'type' => 'widget' , 'widget' => 'my_widget', 'attributes' => ['class' => 'my_widget_style']],
        ],
    ],
]);
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version